Skip to content

Commit

Permalink
Merge pull request #16196 from michaelnebel/misc/expected-changes-usa…
Browse files Browse the repository at this point in the history
…geinfo

Print usage information for accept-expected-changes script in case PR…
  • Loading branch information
RasmusWL authored Apr 16, 2024
2 parents 9671e05 + 52be657 commit ec862eb
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions misc/scripts/accept-expected-changes-from-ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,19 @@ def ok_job_name(job_name: str) -> bool:
print("Expected output in semmle-code changed!")


def printHelp():
print("""Usage:
python3 accept-expected-changes-from-ci.py [PR-number|SHA]
Example invocations:
$ python3 accept-expected-changes-from-ci.py 1234
$ python3 accept-expected-changes-from-ci.py d88a8130386b720de6cac747d1bd2dd527769467
Requirements:
- The 'gh' command line tool must be installed and authenticated.
- The CI check must have finished.
""")

if __name__ == "__main__":

level = logging.INFO
Expand Down Expand Up @@ -462,10 +475,16 @@ def ok_job_name(job_name: str) -> bool:
args = parser.parse_args()

if args.posarg is None:
pr_number_response = subprocess.check_output([
"gh", "pr", "view", "--json", "number"
]).decode("utf-8")
pr_number = json.loads(pr_number_response)["number"]
try:
pr_number_response = subprocess.check_output([
"gh", "pr", "view", "--json", "number"
]).decode("utf-8")
pr_number = json.loads(pr_number_response)["number"]
except:
print("Could not auto detect PR number.")
print("")
printHelp()
sys.exit(1)
else:
if len(args.posarg) > 10:
override_sha = args.posarg
Expand Down

0 comments on commit ec862eb

Please sign in to comment.