Chromium Code Reviews| Index: git_merge_base_tag.py |
| diff --git a/git_merge_base_tag.py b/git_merge_base_tag.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..a59bddc8f79b0c7bd0e94d6ee0f01f0557d66991 |
| --- /dev/null |
| +++ b/git_merge_base_tag.py |
| @@ -0,0 +1,44 @@ |
| +#!/usr/bin/env python |
| +# Copyright 2014 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +""" |
| +Explicitly set/remove the merge-base for the current branch. |
| + |
| +This manually set merge base will be a stand-in for `git merge-base` for the |
| +purposes of the chromium depot_tools git extensions. If the |merge_base| |
| +parameter is omitted the merge-base for this branch will be set to the |
| +equivalent of `git merge-base <branch> <upstream>`. |
| +""" |
| + |
| +import argparse |
| +import sys |
| + |
| +from subprocess2 import CalledProcessError |
| + |
| +from git_common import remove_merge_base, manual_merge_base, current_branch |
| + |
| + |
| +def main(argv): |
| + parser = argparse.ArgumentParser( |
| + description=__doc__.strip().splitlines()[0], |
| + epilog=''.join(__doc__.strip().splitlines()[1:])) |
| + parser.add_argument( |
| + 'merge_base', nargs='?', |
| + help='The new hash to use as the merge base for the current branch' |
| + ) |
| + opts = parser.parse_args(argv) |
| + |
| + if opts.merge_base: |
| + manual_merge_base(current_branch(), opts.merge_base) |
| + else: |
| + try: |
| + remove_merge_base(current_branch()) |
|
agable
2014/03/21 01:14:21
running this with no argument removes the tag? Tha
iannucci
2014/03/22 04:17:35
Well, the helptext does say that. I guess no args
|
| + except CalledProcessError: |
| + print "No merge base currently exists for this branch." |
| + return 0 |
| + |
| + |
| +if __name__ == '__main__': |
| + sys.exit(main(sys.argv[1:])) |