-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
65953d1
commit ecf7b47
Showing
2 changed files
with
65 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import argparse | ||
import subprocess | ||
|
||
def constant(f): | ||
def fset(self, value): | ||
raise TypeError | ||
def fget(self): | ||
return f() | ||
return property(fget, fset) | ||
|
||
class _Const(object): | ||
@constant | ||
def GET_PR_DETAILS_CLI_COMMAND() -> str: | ||
return 'gh pr list --json body --repo {repository} --state merged --search {commit_sha}' | ||
|
||
CONST = _Const() | ||
|
||
def setupArgumentsParsing(): | ||
parser = argparse.ArgumentParser(description="Utility to tag ADO workitem with deployment environemnt", exit_on_error=False) | ||
parser.add_argument('--gh-token', type=str, required=False, dest='gh_token') | ||
parser.add_argument('--repository', type=str, required=True, dest='repository') | ||
parser.add_argument('--commit-sha', type=str, required=True, dest='commit_sha') | ||
return parser.parse_args() | ||
|
||
def extractAdoReferenceFromPR(args): | ||
prData = subprocess.run(args=[CONST.GET_PR_DETAILS_CLI_COMMAND.format(repository = args.repository, commit_sha = args.commit_sha)], capture_output=True, shell=True, text=True) | ||
print(prData) | ||
|
||
|
||
def main(): | ||
args = setupArgumentsParsing() | ||
extractAdoReferenceFromPR(args) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |