Show More
@@ -24,16 +24,17 b' from rhodecode_api import RhodeCodeAPI' | |||||
24 |
|
24 | |||
25 |
|
25 | |||
26 | def add_api_pr_args(parser): |
|
26 | def add_api_pr_args(parser): | |
|
27 | parser.add_argument("--url", help="Rhodecode host url", required=True) | |||
27 | parser.add_argument("--token", help="Rhodecode user token", required=True) |
|
28 | parser.add_argument("--token", help="Rhodecode user token", required=True) | |
28 | parser.add_argument("--url", help="Rhodecode host url", required=True) |
|
|||
29 | parser.add_argument("--repoid", help="Repo id", required=True) |
|
29 | parser.add_argument("--repoid", help="Repo id", required=True) | |
30 | parser.add_argument("--prid", help="Pull request id", required=True) |
|
|||
31 | parser.add_argument("--message", help="Comment to add", required=True) |
|
30 | parser.add_argument("--message", help="Comment to add", required=True) | |
32 |
|
||||
33 | parser.add_argument("--status", help="Status to set (approved|rejected)") |
|
31 | parser.add_argument("--status", help="Status to set (approved|rejected)") | |
34 | parser.add_argument( |
|
32 | parser.add_argument( | |
|
33 | "--prid", | |||
|
34 | help="(Optional) Pull request id") | |||
|
35 | parser.add_argument( | |||
35 | "--commit-id", |
|
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 | def get_pr_head(args): |
|
40 | def get_pr_head(args): | |
@@ -59,18 +60,30 b' if __name__ == "__main__":' | |||||
59 | args = parser.parse_args() |
|
60 | args = parser.parse_args() | |
60 | status = args.status |
|
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 | if args.commit_id and status: |
|
69 | if args.commit_id and status: | |
63 | if not pr_has_same_head(args): |
|
70 | if not pr_has_same_head(args): | |
64 | # PR updated, don't set status |
|
71 | # PR updated, don't set status | |
65 | status = None |
|
72 | status = None | |
66 |
|
73 | |||
67 | rc = RhodeCodeAPI(args.url, args.token) |
|
|||
68 | resp = rc.comment_pull_request( |
|
74 | resp = rc.comment_pull_request( | |
69 | repoid=args.repoid, |
|
75 | repoid=args.repoid, | |
70 | pullrequestid=int(args.prid), |
|
76 | pullrequestid=int(args.prid), | |
71 | message=args.message, |
|
77 | message=args.message, | |
72 | status=status |
|
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 | if resp['error']: |
|
88 | if resp['error']: | |
76 | raise Exception(resp['error']) |
|
89 | raise Exception(resp['error']) |
General Comments 0
You need to be logged in to leave comments.
Login now