summaryrefslogtreecommitdiff
path: root/tools/patman/main.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-07-05 21:41:49 -0600
committerSimon Glass <sjg@chromium.org>2020-07-20 11:37:46 -0600
commitf36537597583a75f357b3927b1e5d816822c90db (patch)
treebdcd7d258d0606fba19c2e33b9b5ea5263e35d35 /tools/patman/main.py
parent2e9a0cdfa8456636392f24dcc47e3270bd4818b7 (diff)
patman: Move main code out to a control module
To make testing easier, move the code out from main into a separate 'control' module and split it into four parts: setup, preparing patches, checking patches and emailing patches. Add comments and fix a few code-style issues while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/patman/main.py')
-rwxr-xr-xtools/patman/main.py57
1 files changed, 2 insertions, 55 deletions
diff --git a/tools/patman/main.py b/tools/patman/main.py
index 03668d1bb8..2432d31871 100755
--- a/tools/patman/main.py
+++ b/tools/patman/main.py
@@ -18,10 +18,9 @@ if __name__ == "__main__":
sys.path.append(os.path.join(our_path, '..'))
# Our modules
-from patman import checkpatch
from patman import command
+from patman import control
from patman import gitutil
-from patman import patchstream
from patman import project
from patman import settings
from patman import terminal
@@ -128,56 +127,4 @@ elif options.full_help:
# Process commits, produce patches files, check them, email them
else:
- gitutil.Setup()
-
- if options.count == -1:
- # Work out how many patches to send if we can
- options.count = gitutil.CountCommitsToBranch() - options.start
-
- col = terminal.Color()
- if not options.count:
- str = 'No commits found to process - please use -c flag'
- sys.exit(col.Color(col.RED, str))
-
- # Read the metadata from the commits
- if options.count:
- series = patchstream.GetMetaData(options.start, options.count)
- cover_fname, args = gitutil.CreatePatches(options.start, options.count,
- options.ignore_binary, series)
-
- # Fix up the patch files to our liking, and insert the cover letter
- patchstream.FixPatches(series, args)
- if cover_fname and series.get('cover'):
- patchstream.InsertCoverLetter(cover_fname, series, options.count)
-
- # Do a few checks on the series
- series.DoChecks()
-
- # Check the patches, and run them through 'git am' just to be sure
- if options.check_patch:
- ok = checkpatch.CheckPatches(options.verbose, args)
- else:
- ok = True
-
- cc_file = series.MakeCcFile(options.process_tags, cover_fname,
- not options.ignore_bad_tags,
- options.add_maintainers, options.limit)
-
- # Email the patches out (giving the user time to check / cancel)
- cmd = ''
- its_a_go = ok or options.ignore_errors
- if its_a_go:
- cmd = gitutil.EmailPatches(series, cover_fname, args,
- options.dry_run, not options.ignore_bad_tags, cc_file,
- in_reply_to=options.in_reply_to, thread=options.thread,
- smtp_server=options.smtp_server)
- else:
- print(col.Color(col.RED, "Not sending emails due to errors/warnings"))
-
- # For a dry run, just show our actions as a sanity check
- if options.dry_run:
- series.ShowActions(args, cmd, options.process_tags)
- if not its_a_go:
- print(col.Color(col.RED, "Email would not be sent"))
-
- os.remove(cc_file)
+ control.send(options)