blob: 33366d28b90098e59f459a8e59fc1b851f0bdebf [file] [log] [blame]
iannucci@chromium.orgc050a5b2014-03-26 06:18:50 +00001#!/usr/bin/env python
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
6import argparse
7import sys
8
sbc@chromium.org71437c02015-04-09 19:29:40 +00009import git_common
iannucci@chromium.orgc050a5b2014-03-26 06:18:50 +000010
11def main(args):
12 parser = argparse.ArgumentParser()
13 parser.add_argument(
14 '-m', '--message', metavar='<msg>', default='git squash commit.',
15 help='Use the given <msg> as the first line of the commit message.')
16 opts = parser.parse_args(args)
sbc@chromium.org71437c02015-04-09 19:29:40 +000017 if git_common.is_dirty_git_tree('squash-branch'):
18 return 1
19 git_common.squash_current_branch(opts.message)
sbc@chromium.org013731e2015-02-26 18:28:43 +000020 return 0
21
iannucci@chromium.orgc050a5b2014-03-26 06:18:50 +000022
23if __name__ == '__main__':
sbc@chromium.org013731e2015-02-26 18:28:43 +000024 try:
25 sys.exit(main(sys.argv[1:]))
26 except KeyboardInterrupt:
27 sys.stderr.write('interrupted\n')
28 sys.exit(1)