-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathset-github-status
executable file
·79 lines (58 loc) · 2.25 KB
/
set-github-status
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python
from __future__ import print_function
from argparse import ArgumentParser
import logging
import sys
from alibot_helpers.github_utilities import setGithubStatus, GithubCachedClient
# Just for the moment
DEFAULT_REPO = "alibuild"
DEFAULT_USER = "alisw"
def parse_args():
usage = "set-github-status "
usage += "[-d] [-n] -c <commit> -s <status> [-m <status-message>] [-u <target-url> | -k]"
parser = ArgumentParser(usage=usage)
parser.add_argument("--commit", "-c",
required=True,
help=("Commit that the status refers to, in "
"<org>/<project>@<ref> format"))
parser.add_argument("--status", "-s",
required=True,
help="Status to set in <status-id>/<status> format")
parser.add_argument("--message", "-m",
default="",
help="Message relative to the status (default='')")
url = parser.add_mutually_exclusive_group()
url.add_argument("--url", "-u", default="",
help="Target URL for the report (default=%(default)s)")
url.add_argument("--keep-url", "-k", action="store_true",
help="Copy the target URL from the existing status.")
parser.add_argument("--debug", "-d",
action="store_true",
default=False,
help="Target url for the report")
parser.add_argument("--dry-run", "-n",
action="store_true",
dest="dryRun",
default=False,
help="Dry run. Do not actually modify the state")
args = parser.parse_args()
if args.debug:
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
return args
def main():
args = parse_args()
if args.dryRun:
print("Dry run specified. Not executing")
sys.exit(0)
with GithubCachedClient() as cgh:
try:
setGithubStatus(cgh, args)
except RuntimeError as e:
print(e.message, file=sys.stderr)
sys.exit(1)
finally:
cgh.printStats()
sys.exit(0)
if __name__ == "__main__":
main()