• Home
  • Raw
  • Download

Lines Matching +full:- +full:- +full:branch

8 def print_(args: argparse.Namespace, success: bool, message: str) -> None:
41 def is_commit_valid(commit: str) -> bool:
42 ret = subprocess.call(['git', 'cat-file', '-e', commit],
48 def branch_has_commit(upstream: str, branch: str, commit: str) -> bool:
50 Returns True if the commit is actually present in the branch
52 ret = subprocess.call(['git', 'merge-base', '--is-ancestor',
53 commit, upstream + '/' + branch],
59 def branch_has_backport_of_commit(upstream: str, branch: str, commit: str) -> str:
61 Returns the commit hash if the commit has been backported to the branch,
64 out = subprocess.check_output(['git', 'log', '--format=%H',
65 branch + '-branchpoint..' + upstream + '/' + branch,
66 '--grep', 'cherry picked from commit ' + commit],
71 def canonicalize_commit(commit: str) -> str:
73 Takes a commit-ish and returns a commit sha1 if the commit exists
80 out = subprocess.check_output(['git', 'rev-parse', commit],
85 def validate_branch(branch: str) -> str:
86 if '/' not in branch:
87 raise argparse.ArgumentTypeError('must be in the form `remote/branch`')
89 out = subprocess.check_output(['git', 'remote', '--verbose'],
92 (upstream, _) = branch.split('/')
101 if not is_commit_valid(branch):
102 raise argparse.ArgumentTypeError('Invalid branch: ' + branch)
104 return branch
109 Returns 0 if the commit is present in the branch,
116 parser.add_argument('branch',
118 help='branch to check, in the form `remote/branch`')
119 parser.add_argument('--quiet',
122 parser.add_argument('--color',
128 (upstream, branch) = args.branch.split('/')
130 if branch_has_commit(upstream, branch, args.commit):
131 print_(args, True, 'Commit ' + args.commit + ' is in branch ' + branch)
134 backport = branch_has_backport_of_commit(upstream, branch, args.commit)
137 … 'Commit ' + args.commit + ' was backported to branch ' + branch + ' as commit ' + backport)
140 print_(args, False, 'Commit ' + args.commit + ' is NOT in branch ' + branch)