Josip Sokcevic | 4de5dea | 2022-03-23 21:15:14 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
iannucci@chromium.org | c050a5b | 2014-03-26 06:18:50 +0000 | [diff] [blame] | 2 | # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | import argparse |
| 7 | import sys |
| 8 | |
sbc@chromium.org | 71437c0 | 2015-04-09 19:29:40 +0000 | [diff] [blame] | 9 | import git_common |
iannucci@chromium.org | c050a5b | 2014-03-26 06:18:50 +0000 | [diff] [blame] | 10 | |
Mike Frysinger | 124bb8e | 2023-09-06 05:48:55 +0000 | [diff] [blame] | 11 | |
iannucci@chromium.org | c050a5b | 2014-03-26 06:18:50 +0000 | [diff] [blame] | 12 | def main(args): |
Mike Frysinger | 124bb8e | 2023-09-06 05:48:55 +0000 | [diff] [blame] | 13 | parser = argparse.ArgumentParser() |
| 14 | parser.add_argument( |
| 15 | '-m', |
| 16 | '--message', |
| 17 | metavar='<msg>', |
| 18 | default=None, |
| 19 | help='Use the given <msg> as the first line of the commit message.') |
| 20 | opts = parser.parse_args(args) |
| 21 | if git_common.is_dirty_git_tree('squash-branch'): |
| 22 | return 1 |
| 23 | git_common.squash_current_branch(opts.message) |
| 24 | return 0 |
sbc@chromium.org | 013731e | 2015-02-26 18:28:43 +0000 | [diff] [blame] | 25 | |
iannucci@chromium.org | c050a5b | 2014-03-26 06:18:50 +0000 | [diff] [blame] | 26 | |
| 27 | if __name__ == '__main__': |
Mike Frysinger | 124bb8e | 2023-09-06 05:48:55 +0000 | [diff] [blame] | 28 | try: |
| 29 | sys.exit(main(sys.argv[1:])) |
| 30 | except KeyboardInterrupt: |
| 31 | sys.stderr.write('interrupted\n') |
| 32 | sys.exit(1) |