##// END OF EJS Templates
notify-script: allow to comment also on single commit
marcink -
r353:d5c4e7ee default
parent child Browse files
Show More
@@ -24,16 +24,17 b' from rhodecode_api import RhodeCodeAPI'
24 24
25 25
26 26 def add_api_pr_args(parser):
27 parser.add_argument("--url", help="Rhodecode host url", required=True)
27 28 parser.add_argument("--token", help="Rhodecode user token", required=True)
28 parser.add_argument("--url", help="Rhodecode host url", required=True)
29 29 parser.add_argument("--repoid", help="Repo id", required=True)
30 parser.add_argument("--prid", help="Pull request id", required=True)
31 30 parser.add_argument("--message", help="Comment to add", required=True)
32
33 31 parser.add_argument("--status", help="Status to set (approved|rejected)")
34 32 parser.add_argument(
33 "--prid",
34 help="(Optional) Pull request id")
35 parser.add_argument(
35 36 "--commit-id",
36 help="Expected commit ID for source repo")
37 help="(Optional) Expected commit ID for source repo")
37 38
38 39
39 40 def get_pr_head(args):
@@ -59,18 +60,30 b' if __name__ == "__main__":'
59 60 args = parser.parse_args()
60 61 status = args.status
61 62
63 rc = RhodeCodeAPI(args.url, args.token)
64
65 if not (args.prid or args.commit_id):
66 raise AttributeError('You must specify --prid or --commit-id')
67
68 if args.prid:
62 69 if args.commit_id and status:
63 70 if not pr_has_same_head(args):
64 71 # PR updated, don't set status
65 72 status = None
66 73
67 rc = RhodeCodeAPI(args.url, args.token)
68 74 resp = rc.comment_pull_request(
69 75 repoid=args.repoid,
70 76 pullrequestid=int(args.prid),
71 77 message=args.message,
72 78 status=status
73 79 )
80 elif args.commit_id:
81 resp = rc.comment_commit(
82 repoid=args.repoid,
83 commit_id=args.commit_id,
84 message=args.message,
85 status=status,
86 )
74 87
75 88 if resp['error']:
76 89 raise Exception(resp['error'])
General Comments 0
You need to be logged in to leave comments. Login now