Warn before uploading more than one commit to Gerrit.
BUG=none
Review URL: https://codereview.chromium.org/259523006
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@267480 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/git_cl.py b/git_cl.py
index a47da6d..59c2d4b 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -1495,6 +1495,16 @@
return 1
if CHANGE_ID not in change_desc.description:
AddChangeIdToCommitMessage(options, args)
+
+ commits = RunGit(['rev-list', '%s/%s...' % (remote, branch)]).splitlines()
+ if len(commits) > 1:
+ print('WARNING: This will upload %d commits. Run the following command '
+ 'to see which commits will be uploaded: ' % len(commits))
+ print('git log %s/%s...' % (remote, branch))
+ print('You can also use `git squash-branch` to squash these into a single'
+ 'commit.')
+ ask_for_data('About to upload; enter to confirm.')
+
if options.reviewers:
change_desc.update_reviewers(options.reviewers)
diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py
index 9234fb2..2d20440 100755
--- a/tests/git_cl_test.py
+++ b/tests/git_cl_test.py
@@ -588,6 +588,7 @@
description)
]
calls += [
+ ((['git', 'rev-list', 'origin/master...'],), ''),
((['git', 'config', 'rietveld.cc'],), '')
]
receive_pack = '--receive-pack=git receive-pack '