blob: 76d95e3118da0ffbd062c3f9c5911363a352ef00 [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')
Tzung-Bi Shih231fada2019-09-02 00:54:59 +0800179
180 # It is possible that multiple Change-Ids are in the commit message
181 # (due to cherry picking). We only want to pull out the first one.
182 changeid_match = re.search('^Change-Id: (.*)$',
183 old_commit_message, re.MULTILINE)
184 if changeid_match:
185 args['changeid'] = changeid_match.group(1)
186
Guenter Roeckf47a50c2018-07-25 12:41:36 -0700187 if args['bug'] == parser.get_default('bug') and \
188 re.findall('BUG=(.*)$', old_commit_message, re.MULTILINE):
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800189 args['bug'] = '\nBUG='.join(re.findall('BUG=(.*)$',
190 old_commit_message,
191 re.MULTILINE))
Guenter Roeckf47a50c2018-07-25 12:41:36 -0700192 if args['test'] == parser.get_default('test') and \
193 re.findall('TEST=(.*)$', old_commit_message, re.MULTILINE):
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800194 args['test'] = '\nTEST='.join(re.findall('TEST=(.*)$',
195 old_commit_message,
196 re.MULTILINE))
197 # TODO: deal with multiline BUG/TEST better
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800198
Guenter Roeckf47a50c2018-07-25 12:41:36 -0700199 if args['bug'] is None or args['test'] is None:
Tzung-Bi Shih196d31e2019-09-01 18:16:28 +0800200 parser.error('BUG=/TEST= lines are required; --replace can help '
Stephen Boyde6fdf912018-11-09 10:30:57 -0800201 'automate, or set via --bug/--test')
Guenter Roeckf47a50c2018-07-25 12:41:36 -0700202
Tzung-Bi Shih5100c742019-09-02 10:28:32 +0800203 if args['debug']:
204 pprint.pprint(args)
205
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800206 while len(args['locations']) > 0:
207 location = args['locations'].pop(0)
208
Tzung-Bi Shih5100c742019-09-02 10:28:32 +0800209 if args['debug']:
210 print('location=%s' % location)
211
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800212 patchwork_match = re.match(
Douglas Anderson4a974f02019-06-03 08:57:15 -0700213 r'pw://(([^/]+)/)?(\d+)', location
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800214 )
215 linux_match = re.match(
216 r'linux://([0-9a-f]+)', location
217 )
218 fromgit_match = re.match(
Stephen Boyd66ea1912018-10-30 11:26:54 -0700219 r'(from)?git://([^/\#]+)/([^#]+)/([0-9a-f]+)$', location
220 )
221 gitfetch_match = re.match(
222 r'((git|https)://.+)#(.+)/([0-9a-f]+)$', location
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800223 )
224
225 if patchwork_match is not None:
Brian Norris9f8a2be2018-06-01 11:14:08 -0700226 pw_project = patchwork_match.group(2)
227 patch_id = int(patchwork_match.group(3))
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800228
Tzung-Bi Shih5100c742019-09-02 10:28:32 +0800229 if args['debug']:
230 print('patchwork match: pw_project=%s, patch_id=%d' %
231 (pw_project, patch_id))
232
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800233 if args['tag'] is None:
234 args['tag'] = 'FROMLIST: '
235
Brian Norris2d4e9762018-08-15 13:11:47 -0700236 url = _get_pw_url(pw_project)
Douglas Andersonb6a10fe2019-08-12 13:53:30 -0700237 opener = urllib.urlopen('%s/patch/%d/mbox' % (url, patch_id))
Brian Norris2d4e9762018-08-15 13:11:47 -0700238 if opener.getcode() != 200:
239 sys.stderr.write('Error: could not download patch - error code %d\n' \
240 % opener.getcode())
241 sys.exit(1)
242 patch_contents = opener.read()
Brian Norris9f8a2be2018-06-01 11:14:08 -0700243
Brian Norris2d4e9762018-08-15 13:11:47 -0700244 if not patch_contents:
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800245 sys.stderr.write('Error: No patch content found\n')
246 sys.exit(1)
Guenter Roeckabe49d82018-07-25 14:11:48 -0700247
Brian Norris2d4e9762018-08-15 13:11:47 -0700248 if args['source_line'] is None:
249 args['source_line'] = '(am from %s/patch/%d/)' % (url, patch_id)
Brian Norrisc3421042018-08-15 14:17:26 -0700250 message_id = mailbox.Message(patch_contents)['Message-Id']
251 message_id = re.sub('^<|>$', '', message_id.strip())
252 args['source_line'] += \
253 '\n(also found at https://lkml.kernel.org/r/%s)' % \
254 message_id
Brian Norris2d4e9762018-08-15 13:11:47 -0700255
Guenter Roeckabe49d82018-07-25 14:11:48 -0700256 if args['replace']:
257 subprocess.call(['git', 'reset', '--hard', 'HEAD~1'])
258
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800259 git_am = subprocess.Popen(['git', 'am', '-3'], stdin=subprocess.PIPE)
Brian Norris2d4e9762018-08-15 13:11:47 -0700260 git_am.communicate(patch_contents)
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800261 ret = git_am.returncode
262 elif linux_match:
263 commit = linux_match.group(1)
264
Tzung-Bi Shih5100c742019-09-02 10:28:32 +0800265 if args['debug']:
266 print('linux match: commit=%s' % commit)
267
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800268 # Confirm a 'linux' remote is setup.
Guenter Roeckd66daa72018-04-19 10:31:25 -0700269 linux_remote = _find_linux_remote()
270 if not linux_remote:
271 sys.stderr.write('Error: need a valid upstream remote\n')
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800272 sys.exit(1)
273
Guenter Roeckd66daa72018-04-19 10:31:25 -0700274 linux_master = '%s/master' % linux_remote
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800275 ret = subprocess.call(['git', 'merge-base', '--is-ancestor',
Guenter Roeckd66daa72018-04-19 10:31:25 -0700276 commit, linux_master])
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800277 if ret:
Guenter Roeckd66daa72018-04-19 10:31:25 -0700278 sys.stderr.write('Error: Commit not in %s\n' % linux_master)
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800279 sys.exit(1)
280
281 if args['source_line'] is None:
282 git_pipe = subprocess.Popen(['git', 'rev-parse', commit],
283 stdout=subprocess.PIPE)
284 commit = git_pipe.communicate()[0].strip()
285
286 args['source_line'] = ('(cherry picked from commit %s)' %
287 (commit))
288 if args['tag'] is None:
289 args['tag'] = 'UPSTREAM: '
290
Guenter Roeckabe49d82018-07-25 14:11:48 -0700291 if args['replace']:
292 subprocess.call(['git', 'reset', '--hard', 'HEAD~1'])
293
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800294 ret = subprocess.call(['git', 'cherry-pick', commit])
295 elif fromgit_match is not None:
Stephen Boyd66ea1912018-10-30 11:26:54 -0700296 remote = fromgit_match.group(2)
297 branch = fromgit_match.group(3)
298 commit = fromgit_match.group(4)
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800299
Tzung-Bi Shih5100c742019-09-02 10:28:32 +0800300 if args['debug']:
301 print('fromgit match: remote=%s branch=%s commit=%s' %
302 (remote, branch, commit))
303
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800304 ret = subprocess.call(['git', 'merge-base', '--is-ancestor',
305 commit, '%s/%s' % (remote, branch)])
306 if ret:
307 sys.stderr.write('Error: Commit not in %s/%s\n' %
308 (remote, branch))
309 sys.exit(1)
310
311 git_pipe = subprocess.Popen(['git', 'remote', 'get-url', remote],
312 stdout=subprocess.PIPE)
313 url = git_pipe.communicate()[0].strip()
314
315 if args['source_line'] is None:
316 git_pipe = subprocess.Popen(['git', 'rev-parse', commit],
317 stdout=subprocess.PIPE)
318 commit = git_pipe.communicate()[0].strip()
319
320 args['source_line'] = \
321 '(cherry picked from commit %s\n %s %s)' % \
322 (commit, url, branch)
323 if args['tag'] is None:
324 args['tag'] = 'FROMGIT: '
325
Guenter Roeckabe49d82018-07-25 14:11:48 -0700326 if args['replace']:
327 subprocess.call(['git', 'reset', '--hard', 'HEAD~1'])
328
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800329 ret = subprocess.call(['git', 'cherry-pick', commit])
Stephen Boyd66ea1912018-10-30 11:26:54 -0700330 elif gitfetch_match is not None:
331 remote = gitfetch_match.group(1)
332 branch = gitfetch_match.group(3)
333 commit = gitfetch_match.group(4)
334
Tzung-Bi Shih5100c742019-09-02 10:28:32 +0800335 if args['debug']:
336 print('gitfetch match: remote=%s branch=%s commit=%s' %
337 (remote, branch, commit))
338
Stephen Boyd66ea1912018-10-30 11:26:54 -0700339 ret = subprocess.call(['git', 'fetch', remote, branch])
340 if ret:
341 sys.stderr.write('Error: Branch not in %s\n' % remote)
342 sys.exit(1)
343
344 url = remote
345
346 if args['source_line'] is None:
347 git_pipe = subprocess.Popen(['git', 'rev-parse', commit],
348 stdout=subprocess.PIPE)
349 commit = git_pipe.communicate()[0].strip()
350
351 args['source_line'] = \
352 '(cherry picked from commit %s\n %s %s)' % \
353 (commit, url, branch)
354 if args['tag'] is None:
355 args['tag'] = 'FROMGIT: '
356
357 ret = subprocess.call(['git', 'cherry-pick', commit])
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800358 else:
359 sys.stderr.write('Don\'t know what "%s" means.\n' % location)
360 sys.exit(1)
361
362 if ret != 0:
Guenter Roeckbdbb9cc2018-04-19 10:05:08 -0700363 conflicts = _get_conflicts()
Douglas Anderson2108e532018-04-30 09:50:42 -0700364 if args['tag'] == 'UPSTREAM: ':
365 args['tag'] = 'BACKPORT: '
366 else:
367 args['tag'] = 'BACKPORT: ' + args['tag']
Guenter Roeckbdbb9cc2018-04-19 10:05:08 -0700368 _pause_for_merge(conflicts)
369 else:
Douglas Andersonb6a10fe2019-08-12 13:53:30 -0700370 conflicts = ''
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800371
372 # extract commit message
373 commit_message = subprocess.check_output(
374 ['git', 'show', '-s', '--format=%B', 'HEAD']
375 ).strip('\n')
376
Guenter Roeck2e4f2512018-04-24 09:20:51 -0700377 # Remove stray Change-Id, most likely from merge resolution
378 commit_message = re.sub(r'Change-Id:.*\n?', '', commit_message)
379
Brian Norris7a41b982018-06-01 10:28:29 -0700380 # Note the source location before tagging anything else
381 commit_message += '\n' + args['source_line']
382
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800383 # add automatic Change ID, BUG, and TEST (and maybe signoff too) so
384 # next commands know where to work on
385 commit_message += '\n'
Guenter Roeckbdbb9cc2018-04-19 10:05:08 -0700386 commit_message += conflicts
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800387 commit_message += '\n' + 'BUG=' + args['bug']
Harry Cuttsae372f32019-02-12 18:01:14 -0800388 commit_message += '\n' + _wrap_commit_line('TEST', args['test'])
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800389 if args['signoff']:
390 extra = ['-s']
391 else:
392 extra = []
Stephen Boydaa4e7e02018-11-09 08:48:46 -0800393 subprocess.Popen(
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800394 ['git', 'commit'] + extra + ['--amend', '-F', '-'],
395 stdin=subprocess.PIPE
396 ).communicate(commit_message)
397
398 # re-extract commit message
399 commit_message = subprocess.check_output(
400 ['git', 'show', '-s', '--format=%B', 'HEAD']
401 ).strip('\n')
402
403 # replace changeid if needed
404 if args['changeid'] is not None:
405 commit_message = re.sub(r'(Change-Id: )(\w+)', r'\1%s' %
406 args['changeid'], commit_message)
407 args['changeid'] = None
408
409 # decorate it that it's from outside
410 commit_message = args['tag'] + commit_message
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800411
412 # commit everything
Stephen Boydaa4e7e02018-11-09 08:48:46 -0800413 subprocess.Popen(
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800414 ['git', 'commit', '--amend', '-F', '-'], stdin=subprocess.PIPE
415 ).communicate(commit_message)
416
Chirantan Ekbote4b08e712019-06-12 15:35:41 +0900417 return 0
Alexandru M Stanfb5b5ee2014-12-04 13:32:55 -0800418
419if __name__ == '__main__':
420 sys.exit(main(sys.argv[1:]))