git_squash_branch.py 810 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env python3
  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. import argparse
  6. import sys
  7. import git_common
  8. def main(args):
  9. parser = argparse.ArgumentParser()
  10. parser.add_argument(
  11. '-m',
  12. '--message',
  13. metavar='<msg>',
  14. default=None,
  15. help='Use the given <msg> as the first line of the commit message.')
  16. opts = parser.parse_args(args)
  17. if git_common.is_dirty_git_tree('squash-branch'):
  18. return 1
  19. git_common.squash_current_branch(opts.message)
  20. return 0
  21. if __name__ == '__main__':
  22. try:
  23. sys.exit(main(sys.argv[1:]))
  24. except KeyboardInterrupt:
  25. sys.stderr.write('interrupted\n')
  26. sys.exit(1)