diff options
author | Scott Dodson <sdodson@redhat.com> | 2017-01-10 16:27:29 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-10 16:27:29 -0500 |
commit | 393eccd3a5347a13eda5d627f3cc35aeeb42f1cc (patch) | |
tree | 668806139fc108ce6763cc95a640aedffa8a4ecf /git/parent.py | |
parent | 706c582b2482d5cc3a4fb28b348ce5b856fc9c26 (diff) | |
parent | 33da32dbcdc5e93e26bccf59d0781a60386b6b04 (diff) | |
download | openshift-393eccd3a5347a13eda5d627f3cc35aeeb42f1cc.tar.gz openshift-393eccd3a5347a13eda5d627f3cc35aeeb42f1cc.tar.bz2 openshift-393eccd3a5347a13eda5d627f3cc35aeeb42f1cc.tar.xz openshift-393eccd3a5347a13eda5d627f3cc35aeeb42f1cc.zip |
Merge pull request #3007 from detiber/toxification
More Toxification
Diffstat (limited to 'git/parent.py')
-rwxr-xr-x | git/parent.py | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/git/parent.py b/git/parent.py deleted file mode 100755 index 92f57df3e..000000000 --- a/git/parent.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# flake8: noqa -# pylint: skip-file -''' - Script to determine if this commit has also - been merged through the stage branch -''' -# -# Usage: -# parent_check.py <branch> <commit_id> -# -# -import sys -import subprocess - -def run_cli_cmd(cmd, in_stdout=None, in_stderr=None): - '''Run a command and return its output''' - if not in_stderr: - proc = subprocess.Popen(cmd, bufsize=-1, stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=False) - else: - proc = subprocess.check_output(cmd, bufsize=-1, stdout=in_stdout, stderr=in_stderr, shell=False) - stdout, stderr = proc.communicate() - if proc.returncode != 0: - return {"rc": proc.returncode, "error": stderr} - else: - return {"rc": proc.returncode, "result": stdout} - -def main(): - '''Check to ensure that the commit that is currently - being submitted is also in the stage branch. - - if it is, succeed - else, fail - ''' - branch = 'prod' - - if sys.argv[1] != branch: - sys.exit(0) - - # git co stg - results = run_cli_cmd(['/usr/bin/git', 'checkout', 'stg']) - - # git pull latest - results = run_cli_cmd(['/usr/bin/git', 'pull']) - - # setup on the <prod> branch in git - results = run_cli_cmd(['/usr/bin/git', 'checkout', 'prod']) - - results = run_cli_cmd(['/usr/bin/git', 'pull']) - # merge the passed in commit into my current <branch> - - commit_id = sys.argv[2] - results = run_cli_cmd(['/usr/bin/git', 'merge', commit_id]) - - # get the differences from stg and <branch> - results = run_cli_cmd(['/usr/bin/git', 'rev-list', '--left-right', 'stg...prod']) - - # exit here with error code if the result coming back is an error - if results['rc'] != 0: - print results['error'] - sys.exit(results['rc']) - - count = 0 - # Each 'result' is a commit - # Walk through each commit and see if it is in stg - for commit in results['result'].split('\n'): - - # continue if it is already in stg - if not commit or commit.startswith('<'): - continue - - # remove the first char '>' - commit = commit[1:] - - # check if any remote branches contain $commit - results = run_cli_cmd(['/usr/bin/git', 'branch', '-q', '-r', '--contains', commit], in_stderr=None) - - # if this comes back empty, nothing contains it, we can skip it as - # we have probably created the merge commit here locally - if results['rc'] == 0 and len(results['result']) == 0: - continue - - # The results generally contain origin/pr/246/merge and origin/pr/246/head - # this is the pull request which would contain the commit in question. - # - # If the results do not contain origin/stg then stage does not contain - # the commit in question. Therefore we need to alert! - if 'origin/stg' not in results['result']: - print "\nFAILED: (These commits are not in stage.)\n" - print "\t%s" % commit - count += 1 - - # Exit with count of commits in #{branch} but not stg - sys.exit(count) - -if __name__ == '__main__': - main() |