Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Side by Side Diff: git_cl.py

Issue 1705193003: Use %B format instead of %s\n\n%b to get the raw commit message from a hash. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # Copyright (C) 2008 Evan Martin <martine@danga.com> 6 # Copyright (C) 2008 Evan Martin <martine@danga.com>
7 7
8 """A git-command for integrating reviews on Rietveld.""" 8 """A git-command for integrating reviews on Rietveld."""
9 9
10 from distutils.version import LooseVersion 10 from distutils.version import LooseVersion
(...skipping 2003 matching lines...) Expand 10 before | Expand all | Expand 10 after
2014 print "\nDescription is empty. Aborting..." 2014 print "\nDescription is empty. Aborting..."
2015 return 1 2015 return 1
2016 2016
2017 if options.title: 2017 if options.title:
2018 print "\nPatch titles (-t) are not supported in Gerrit. Aborting..." 2018 print "\nPatch titles (-t) are not supported in Gerrit. Aborting..."
2019 return 1 2019 return 1
2020 2020
2021 if options.squash: 2021 if options.squash:
2022 # Try to get the message from a previous upload. 2022 # Try to get the message from a previous upload.
2023 shadow_branch = 'refs/heads/git_cl_uploads/' + cl.GetBranch() 2023 shadow_branch = 'refs/heads/git_cl_uploads/' + cl.GetBranch()
2024 message = RunGitSilent(['show', '--format=%s\n\n%b', '-s', shadow_branch]) 2024 message = RunGitSilent(['show', '--format=%B', '-s', shadow_branch])
2025 if not message: 2025 if not message:
2026 if not options.force: 2026 if not options.force:
2027 change_desc.prompt() 2027 change_desc.prompt()
2028 2028
2029 if CHANGE_ID not in change_desc.description: 2029 if CHANGE_ID not in change_desc.description:
2030 # Run the commit-msg hook without modifying the head commit by writing 2030 # Run the commit-msg hook without modifying the head commit by writing
2031 # the commit message to a temporary file and running the hook over it, 2031 # the commit message to a temporary file and running the hook over it,
2032 # then reading the file back in. 2032 # then reading the file back in.
2033 commit_msg_hook = os.path.join(settings.GetRoot(), '.git', 'hooks', 2033 commit_msg_hook = os.path.join(settings.GetRoot(), '.git', 'hooks',
2034 'commit-msg') 2034 'commit-msg')
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2071 # will create additional CLs when uploading. 2071 # will create additional CLs when uploading.
2072 if (RunGitSilent(['rev-parse', upstream_branch + ':']) != 2072 if (RunGitSilent(['rev-parse', upstream_branch + ':']) !=
2073 RunGitSilent(['rev-parse', parent + ':'])): 2073 RunGitSilent(['rev-parse', parent + ':'])):
2074 print 'Upload upstream branch ' + upstream_branch + ' first.' 2074 print 'Upload upstream branch ' + upstream_branch + ' first.'
2075 return 1 2075 return 1
2076 else: 2076 else:
2077 parent = cl.GetCommonAncestorWithUpstream() 2077 parent = cl.GetCommonAncestorWithUpstream()
2078 2078
2079 tree = RunGit(['rev-parse', 'HEAD:']).strip() 2079 tree = RunGit(['rev-parse', 'HEAD:']).strip()
2080 ref_to_push = RunGit(['commit-tree', tree, '-p', parent, 2080 ref_to_push = RunGit(['commit-tree', tree, '-p', parent,
2081 '-m', message]).strip() 2081 '-m', message]).strip()
scottmg 2016/02/18 18:02:48 Will message still be multiline? I think this will
Bernhard Bauer 2016/02/18 20:12:18 Dunno… is that different on Windows? I could imagi
2082 else: 2082 else:
2083 if CHANGE_ID not in change_desc.description: 2083 if CHANGE_ID not in change_desc.description:
2084 AddChangeIdToCommitMessage(options, args) 2084 AddChangeIdToCommitMessage(options, args)
2085 ref_to_push = 'HEAD' 2085 ref_to_push = 'HEAD'
2086 parent = '%s/%s' % (gerrit_remote, branch) 2086 parent = '%s/%s' % (gerrit_remote, branch)
2087 2087
2088 commits = RunGitSilent(['rev-list', '%s..%s' % (parent, 2088 commits = RunGitSilent(['rev-list', '%s..%s' % (parent,
2089 ref_to_push)]).splitlines() 2089 ref_to_push)]).splitlines()
2090 if len(commits) > 1: 2090 if len(commits) > 1:
2091 print('WARNING: This will upload %d commits. Run the following command ' 2091 print('WARNING: This will upload %d commits. Run the following command '
(...skipping 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after
3760 if __name__ == '__main__': 3760 if __name__ == '__main__':
3761 # These affect sys.stdout so do it outside of main() to simplify mocks in 3761 # These affect sys.stdout so do it outside of main() to simplify mocks in
3762 # unit testing. 3762 # unit testing.
3763 fix_encoding.fix_encoding() 3763 fix_encoding.fix_encoding()
3764 colorama.init() 3764 colorama.init()
3765 try: 3765 try:
3766 sys.exit(main(sys.argv[1:])) 3766 sys.exit(main(sys.argv[1:]))
3767 except KeyboardInterrupt: 3767 except KeyboardInterrupt:
3768 sys.stderr.write('interrupted\n') 3768 sys.stderr.write('interrupted\n')
3769 sys.exit(1) 3769 sys.exit(1)
OLDNEW
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698