blob: 7c570decd4c82b9fbc92040b2e0e8d02a913e697 [file] [log] [blame]
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -08001#!/usr/bin/env python2
Mike Frysingerf80ca212018-07-13 15:02:52 -04002# -*- coding: utf-8 -*-
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -08003# Copyright 2017 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
Mike Frysingerf80ca212018-07-13 15:02:52 -04006
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -08007"""This is a tool for picking patches from upstream and applying them."""
8
9from __future__ import print_function
10
Brian Norris9f8a2be2018-06-01 11:14:08 -070011import ConfigParser
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -080012import argparse
Brian Norrisc3421042018-08-15 14:17:26 -070013import mailbox
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -080014import os
Tzung-Bi Shih5100c742019-09-02 10:28:32 +080015import pprint
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -080016import re
17import signal
18import subprocess
19import sys
Harry Cuttsae372f32019-02-12 18:01:14 -080020import textwrap
Brian Norris2d4e9762018-08-15 13:11:47 -070021import urllib
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -080022
23LINUX_URLS = (
24 'git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git',
25 'https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git',
26 'https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux.git',
27)
28
Harry Cuttsae372f32019-02-12 18:01:14 -080029COMMIT_MESSAGE_WIDTH = 75
30
Brian Norris9f8a2be2018-06-01 11:14:08 -070031_PWCLIENTRC = os.path.expanduser('~/.pwclientrc')
32
Guenter Roeckbdbb9cc2018-04-19 10:05:08 -070033def _get_conflicts():
34 """Report conflicting files."""
35 resolutions = ('DD', 'AU', 'UD', 'UA', 'DU', 'AA', 'UU')
36 conflicts = []
Douglas Anderson46287f92018-04-30 09:58:24 -070037 lines = subprocess.check_output(['git', 'status', '--porcelain',
Guenter Roeckbdbb9cc2018-04-19 10:05:08 -070038 '--untracked-files=no']).split('\n')
Douglas Anderson46287f92018-04-30 09:58:24 -070039 for line in lines:
40 if not line:
Guenter Roeckbdbb9cc2018-04-19 10:05:08 -070041 continue
Douglas Anderson46287f92018-04-30 09:58:24 -070042 resolution, name = line.split(None, 1)
Guenter Roeckbdbb9cc2018-04-19 10:05:08 -070043 if resolution in resolutions:
44 conflicts.append(' ' + name)
45 if not conflicts:
Douglas Andersonb6a10fe2019-08-12 13:53:30 -070046 return ''
Guenter Roeckbdbb9cc2018-04-19 10:05:08 -070047 return '\nConflicts:\n%s\n' % '\n'.join(conflicts)
48
Guenter Roeckd66daa72018-04-19 10:31:25 -070049def _find_linux_remote():
50 """Find a remote pointing to a Linux upstream repository."""
51 git_remote = subprocess.Popen(['git', 'remote'], stdout=subprocess.PIPE)
52 remotes = git_remote.communicate()[0].strip()
53 for remote in remotes.splitlines():
54 rurl = subprocess.Popen(['git', 'remote', 'get-url', remote],
55 stdout=subprocess.PIPE)
56 url = rurl.communicate()[0].strip()
57 if not rurl.returncode and url in LINUX_URLS:
58 return remote
59 return None
60
Guenter Roeckbdbb9cc2018-04-19 10:05:08 -070061def _pause_for_merge(conflicts):
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -080062 """Pause and go in the background till user resolves the conflicts."""
63
64 git_root = subprocess.check_output(['git', 'rev-parse',
65 '--show-toplevel']).strip('\n')
66
67 paths = (
68 os.path.join(git_root, '.git', 'rebase-apply'),
69 os.path.join(git_root, '.git', 'CHERRY_PICK_HEAD'),
70 )
71 for path in paths:
72 if os.path.exists(path):
73 sys.stderr.write('Found "%s".\n' % path)
Guenter Roeckbdbb9cc2018-04-19 10:05:08 -070074 sys.stderr.write(conflicts)
Tzung-Bi Shih196d31e2019-09-01 18:16:28 +080075 sys.stderr.write('Please resolve the conflicts and restart the '
76 'shell job when done. Kill this job if you '
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -080077 'aborted the conflict.\n')
78 os.kill(os.getpid(), signal.SIGTSTP)
79 # TODO: figure out what the state is after the merging, and go based on
80 # that (should we abort? skip? continue?)
81 # Perhaps check last commit message to see if it's the one we were using.
82
Brian Norris9f8a2be2018-06-01 11:14:08 -070083def _get_pw_url(project):
84 """Retrieve the patchwork server URL from .pwclientrc.
85
Mike Frysingerf80ca212018-07-13 15:02:52 -040086 Args:
87 project: patchwork project name; if None, we retrieve the default
88 from pwclientrc
Brian Norris9f8a2be2018-06-01 11:14:08 -070089 """
90 config = ConfigParser.ConfigParser()
91 config.read([_PWCLIENTRC])
92
93 if project is None:
94 try:
95 project = config.get('options', 'default')
96 except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
97 sys.stderr.write(
98 'Error: no default patchwork project found in %s.\n'
99 % _PWCLIENTRC)
100 sys.exit(1)
101
102 if not config.has_option(project, 'url'):
Douglas Andersonb6a10fe2019-08-12 13:53:30 -0700103 sys.stderr.write("Error: patchwork URL not found for project '%s'\n"
Brian Norris9f8a2be2018-06-01 11:14:08 -0700104 % project)
105 sys.exit(1)
106
107 url = config.get(project, 'url')
Brian Norris2d4e9762018-08-15 13:11:47 -0700108 # Strip trailing 'xmlrpc' and/or trailing slash.
109 return re.sub('/(xmlrpc/)?$', '', url)
Brian Norris9f8a2be2018-06-01 11:14:08 -0700110
Harry Cuttsae372f32019-02-12 18:01:14 -0800111def _wrap_commit_line(prefix, content):
112 line = prefix + '=' + content
113 indent = ' ' * (len(prefix) + 1)
114 return textwrap.fill(line, COMMIT_MESSAGE_WIDTH, subsequent_indent=indent)
115
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800116def main(args):
117 """This is the main entrypoint for fromupstream.
118
119 Args:
120 args: sys.argv[1:]
121
122 Returns:
123 An int return code.
124 """
125 parser = argparse.ArgumentParser()
126
127 parser.add_argument('--bug', '-b',
Guenter Roeckf47a50c2018-07-25 12:41:36 -0700128 type=str, help='BUG= line')
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800129 parser.add_argument('--test', '-t',
Guenter Roeckf47a50c2018-07-25 12:41:36 -0700130 type=str, help='TEST= line')
Stephen Boyd24b309b2018-11-06 22:11:00 -0800131 parser.add_argument('--crbug', action='append',
132 type=int, help='BUG=chromium: line')
133 parser.add_argument('--buganizer', action='append',
134 type=int, help='BUG=b: line')
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800135 parser.add_argument('--changeid', '-c',
136 help='Overrides the gerrit generated Change-Id line')
137
Tzung-Bi Shihf5d25a82019-09-02 11:40:09 +0800138 parser.add_argument('--replace', '-r',
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800139 action='store_true',
Tzung-Bi Shih196d31e2019-09-01 18:16:28 +0800140 help='Replaces the HEAD commit with this one, taking '
141 'its properties(BUG, TEST, Change-Id). Useful for '
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800142 'updating commits.')
143 parser.add_argument('--nosignoff',
144 dest='signoff', action='store_false')
Tzung-Bi Shih5100c742019-09-02 10:28:32 +0800145 parser.add_argument('--debug', '-d', action='store_true',
146 help='Prints more verbose logs.')
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800147
148 parser.add_argument('--tag',
149 help='Overrides the tag from the title')
150 parser.add_argument('--source', '-s',
151 dest='source_line', type=str,
Tzung-Bi Shih196d31e2019-09-01 18:16:28 +0800152 help='Overrides the source line, last line, ex: '
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800153 '(am from http://....)')
154 parser.add_argument('locations',
Douglas Andersonc77a8b82018-05-04 17:02:03 -0700155 nargs='+',
Tzung-Bi Shih196d31e2019-09-01 18:16:28 +0800156 help='Patchwork ID (pw://### or pw://PROJECT/###, '
157 'where PROJECT is defined in ~/.pwclientrc; if no '
158 'PROJECT is specified, the default is retrieved from '
159 '~/.pwclientrc), '
160 'linux commit like linux://HASH, or '
161 'git reference like git://remote/branch/HASH or '
162 'git://repoURL#branch/HASH or '
Stephen Boyd66ea1912018-10-30 11:26:54 -0700163 'https://repoURL#branch/HASH')
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800164
165 args = vars(parser.parse_args(args))
166
Stephen Boyd24b309b2018-11-06 22:11:00 -0800167 buglist = [args['bug']] if args['bug'] else []
168 if args['buganizer']:
169 buglist += ['b:{0}'.format(x) for x in args['buganizer']]
170 if args['crbug']:
171 buglist += ['chromium:{0}'.format(x) for x in args['crbug']]
Brian Norris667a0cb2018-12-07 09:28:46 -0800172 if buglist:
173 args['bug'] = ', '.join(buglist)
Stephen Boyd24b309b2018-11-06 22:11:00 -0800174
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800175 if args['replace']:
176 old_commit_message = subprocess.check_output(
177 ['git', 'show', '-s', '--format=%B', 'HEAD']
178 ).strip('\n')
Guenter Roeckf7cebec2018-07-26 16:37:21 -0700179 changeid = re.findall('Change-Id: (.*)$', old_commit_message, re.MULTILINE)
180 if changeid:
181 args['changeid'] = changeid[0]
Guenter Roeckf47a50c2018-07-25 12:41:36 -0700182 if args['bug'] == parser.get_default('bug') and \
183 re.findall('BUG=(.*)$', old_commit_message, re.MULTILINE):
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800184 args['bug'] = '\nBUG='.join(re.findall('BUG=(.*)$',
185 old_commit_message,
186 re.MULTILINE))
Guenter Roeckf47a50c2018-07-25 12:41:36 -0700187 if args['test'] == parser.get_default('test') and \
188 re.findall('TEST=(.*)$', old_commit_message, re.MULTILINE):
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800189 args['test'] = '\nTEST='.join(re.findall('TEST=(.*)$',
190 old_commit_message,
191 re.MULTILINE))
192 # TODO: deal with multiline BUG/TEST better
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800193
Guenter Roeckf47a50c2018-07-25 12:41:36 -0700194 if args['bug'] is None or args['test'] is None:
Tzung-Bi Shih196d31e2019-09-01 18:16:28 +0800195 parser.error('BUG=/TEST= lines are required; --replace can help '
Stephen Boyde6fdf912018-11-09 10:30:57 -0800196 'automate, or set via --bug/--test')
Guenter Roeckf47a50c2018-07-25 12:41:36 -0700197
Tzung-Bi Shih5100c742019-09-02 10:28:32 +0800198 if args['debug']:
199 pprint.pprint(args)
200
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800201 while len(args['locations']) > 0:
202 location = args['locations'].pop(0)
203
Tzung-Bi Shih5100c742019-09-02 10:28:32 +0800204 if args['debug']:
205 print('location=%s' % location)
206
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800207 patchwork_match = re.match(
Douglas Anderson4a974f02019-06-03 08:57:15 -0700208 r'pw://(([^/]+)/)?(\d+)', location
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800209 )
210 linux_match = re.match(
211 r'linux://([0-9a-f]+)', location
212 )
213 fromgit_match = re.match(
Stephen Boyd66ea1912018-10-30 11:26:54 -0700214 r'(from)?git://([^/\#]+)/([^#]+)/([0-9a-f]+)$', location
215 )
216 gitfetch_match = re.match(
217 r'((git|https)://.+)#(.+)/([0-9a-f]+)$', location
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800218 )
219
220 if patchwork_match is not None:
Brian Norris9f8a2be2018-06-01 11:14:08 -0700221 pw_project = patchwork_match.group(2)
222 patch_id = int(patchwork_match.group(3))
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800223
Tzung-Bi Shih5100c742019-09-02 10:28:32 +0800224 if args['debug']:
225 print('patchwork match: pw_project=%s, patch_id=%d' %
226 (pw_project, patch_id))
227
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800228 if args['tag'] is None:
229 args['tag'] = 'FROMLIST: '
230
Brian Norris2d4e9762018-08-15 13:11:47 -0700231 url = _get_pw_url(pw_project)
Douglas Andersonb6a10fe2019-08-12 13:53:30 -0700232 opener = urllib.urlopen('%s/patch/%d/mbox' % (url, patch_id))
Brian Norris2d4e9762018-08-15 13:11:47 -0700233 if opener.getcode() != 200:
234 sys.stderr.write('Error: could not download patch - error code %d\n' \
235 % opener.getcode())
236 sys.exit(1)
237 patch_contents = opener.read()
Brian Norris9f8a2be2018-06-01 11:14:08 -0700238
Brian Norris2d4e9762018-08-15 13:11:47 -0700239 if not patch_contents:
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800240 sys.stderr.write('Error: No patch content found\n')
241 sys.exit(1)
Guenter Roeckabe49d82018-07-25 14:11:48 -0700242
Brian Norris2d4e9762018-08-15 13:11:47 -0700243 if args['source_line'] is None:
244 args['source_line'] = '(am from %s/patch/%d/)' % (url, patch_id)
Brian Norrisc3421042018-08-15 14:17:26 -0700245 message_id = mailbox.Message(patch_contents)['Message-Id']
246 message_id = re.sub('^<|>$', '', message_id.strip())
247 args['source_line'] += \
248 '\n(also found at https://lkml.kernel.org/r/%s)' % \
249 message_id
Brian Norris2d4e9762018-08-15 13:11:47 -0700250
Guenter Roeckabe49d82018-07-25 14:11:48 -0700251 if args['replace']:
252 subprocess.call(['git', 'reset', '--hard', 'HEAD~1'])
253
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800254 git_am = subprocess.Popen(['git', 'am', '-3'], stdin=subprocess.PIPE)
Brian Norris2d4e9762018-08-15 13:11:47 -0700255 git_am.communicate(patch_contents)
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800256 ret = git_am.returncode
257 elif linux_match:
258 commit = linux_match.group(1)
259
Tzung-Bi Shih5100c742019-09-02 10:28:32 +0800260 if args['debug']:
261 print('linux match: commit=%s' % commit)
262
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800263 # Confirm a 'linux' remote is setup.
Guenter Roeckd66daa72018-04-19 10:31:25 -0700264 linux_remote = _find_linux_remote()
265 if not linux_remote:
266 sys.stderr.write('Error: need a valid upstream remote\n')
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800267 sys.exit(1)
268
Guenter Roeckd66daa72018-04-19 10:31:25 -0700269 linux_master = '%s/master' % linux_remote
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800270 ret = subprocess.call(['git', 'merge-base', '--is-ancestor',
Guenter Roeckd66daa72018-04-19 10:31:25 -0700271 commit, linux_master])
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800272 if ret:
Guenter Roeckd66daa72018-04-19 10:31:25 -0700273 sys.stderr.write('Error: Commit not in %s\n' % linux_master)
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800274 sys.exit(1)
275
276 if args['source_line'] is None:
277 git_pipe = subprocess.Popen(['git', 'rev-parse', commit],
278 stdout=subprocess.PIPE)
279 commit = git_pipe.communicate()[0].strip()
280
281 args['source_line'] = ('(cherry picked from commit %s)' %
282 (commit))
283 if args['tag'] is None:
284 args['tag'] = 'UPSTREAM: '
285
Guenter Roeckabe49d82018-07-25 14:11:48 -0700286 if args['replace']:
287 subprocess.call(['git', 'reset', '--hard', 'HEAD~1'])
288
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800289 ret = subprocess.call(['git', 'cherry-pick', commit])
290 elif fromgit_match is not None:
Stephen Boyd66ea1912018-10-30 11:26:54 -0700291 remote = fromgit_match.group(2)
292 branch = fromgit_match.group(3)
293 commit = fromgit_match.group(4)
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800294
Tzung-Bi Shih5100c742019-09-02 10:28:32 +0800295 if args['debug']:
296 print('fromgit match: remote=%s branch=%s commit=%s' %
297 (remote, branch, commit))
298
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800299 ret = subprocess.call(['git', 'merge-base', '--is-ancestor',
300 commit, '%s/%s' % (remote, branch)])
301 if ret:
302 sys.stderr.write('Error: Commit not in %s/%s\n' %
303 (remote, branch))
304 sys.exit(1)
305
306 git_pipe = subprocess.Popen(['git', 'remote', 'get-url', remote],
307 stdout=subprocess.PIPE)
308 url = git_pipe.communicate()[0].strip()
309
310 if args['source_line'] is None:
311 git_pipe = subprocess.Popen(['git', 'rev-parse', commit],
312 stdout=subprocess.PIPE)
313 commit = git_pipe.communicate()[0].strip()
314
315 args['source_line'] = \
316 '(cherry picked from commit %s\n %s %s)' % \
317 (commit, url, branch)
318 if args['tag'] is None:
319 args['tag'] = 'FROMGIT: '
320
Guenter Roeckabe49d82018-07-25 14:11:48 -0700321 if args['replace']:
322 subprocess.call(['git', 'reset', '--hard', 'HEAD~1'])
323
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800324 ret = subprocess.call(['git', 'cherry-pick', commit])
Stephen Boyd66ea1912018-10-30 11:26:54 -0700325 elif gitfetch_match is not None:
326 remote = gitfetch_match.group(1)
327 branch = gitfetch_match.group(3)
328 commit = gitfetch_match.group(4)
329
Tzung-Bi Shih5100c742019-09-02 10:28:32 +0800330 if args['debug']:
331 print('gitfetch match: remote=%s branch=%s commit=%s' %
332 (remote, branch, commit))
333
Stephen Boyd66ea1912018-10-30 11:26:54 -0700334 ret = subprocess.call(['git', 'fetch', remote, branch])
335 if ret:
336 sys.stderr.write('Error: Branch not in %s\n' % remote)
337 sys.exit(1)
338
339 url = remote
340
341 if args['source_line'] is None:
342 git_pipe = subprocess.Popen(['git', 'rev-parse', commit],
343 stdout=subprocess.PIPE)
344 commit = git_pipe.communicate()[0].strip()
345
346 args['source_line'] = \
347 '(cherry picked from commit %s\n %s %s)' % \
348 (commit, url, branch)
349 if args['tag'] is None:
350 args['tag'] = 'FROMGIT: '
351
352 ret = subprocess.call(['git', 'cherry-pick', commit])
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800353 else:
354 sys.stderr.write('Don\'t know what "%s" means.\n' % location)
355 sys.exit(1)
356
357 if ret != 0:
Guenter Roeckbdbb9cc2018-04-19 10:05:08 -0700358 conflicts = _get_conflicts()
Douglas Anderson2108e532018-04-30 09:50:42 -0700359 if args['tag'] == 'UPSTREAM: ':
360 args['tag'] = 'BACKPORT: '
361 else:
362 args['tag'] = 'BACKPORT: ' + args['tag']
Guenter Roeckbdbb9cc2018-04-19 10:05:08 -0700363 _pause_for_merge(conflicts)
364 else:
Douglas Andersonb6a10fe2019-08-12 13:53:30 -0700365 conflicts = ''
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800366
367 # extract commit message
368 commit_message = subprocess.check_output(
369 ['git', 'show', '-s', '--format=%B', 'HEAD']
370 ).strip('\n')
371
Guenter Roeck2e4f2512018-04-24 09:20:51 -0700372 # Remove stray Change-Id, most likely from merge resolution
373 commit_message = re.sub(r'Change-Id:.*\n?', '', commit_message)
374
Brian Norris7a41b982018-06-01 10:28:29 -0700375 # Note the source location before tagging anything else
376 commit_message += '\n' + args['source_line']
377
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800378 # add automatic Change ID, BUG, and TEST (and maybe signoff too) so
379 # next commands know where to work on
380 commit_message += '\n'
Guenter Roeckbdbb9cc2018-04-19 10:05:08 -0700381 commit_message += conflicts
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800382 commit_message += '\n' + 'BUG=' + args['bug']
Harry Cuttsae372f32019-02-12 18:01:14 -0800383 commit_message += '\n' + _wrap_commit_line('TEST', args['test'])
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800384 if args['signoff']:
385 extra = ['-s']
386 else:
387 extra = []
Stephen Boydaa4e7e02018-11-09 08:48:46 -0800388 subprocess.Popen(
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800389 ['git', 'commit'] + extra + ['--amend', '-F', '-'],
390 stdin=subprocess.PIPE
391 ).communicate(commit_message)
392
393 # re-extract commit message
394 commit_message = subprocess.check_output(
395 ['git', 'show', '-s', '--format=%B', 'HEAD']
396 ).strip('\n')
397
398 # replace changeid if needed
399 if args['changeid'] is not None:
400 commit_message = re.sub(r'(Change-Id: )(\w+)', r'\1%s' %
401 args['changeid'], commit_message)
402 args['changeid'] = None
403
404 # decorate it that it's from outside
405 commit_message = args['tag'] + commit_message
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800406
407 # commit everything
Stephen Boydaa4e7e02018-11-09 08:48:46 -0800408 subprocess.Popen(
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800409 ['git', 'commit', '--amend', '-F', '-'], stdin=subprocess.PIPE
410 ).communicate(commit_message)
411
Chirantan Ekbote4b08e712019-06-12 15:35:41 +0900412 return 0
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800413
414if __name__ == '__main__':
415 sys.exit(main(sys.argv[1:]))