pst.finalise()
return series
-def get_metadata(branch, start, count):
+def get_metadata(branch, start, count, git_dir=None):
"""Reads out patch series metadata from the commits
This does a 'git log' on the relevant commits and pulls out the tags we
Series: Object containing information about the commits.
"""
top = f"{branch if branch else 'HEAD'}~{start}"
- series = get_metadata_for_list(top, None, count)
- series.base_commit = commit.Commit(gitutil.get_hash(f'{top}~{count}'))
+ series = get_metadata_for_list(top, git_dir, count)
+ series.base_commit = commit.Commit(
+ gitutil.get_hash(f'{top}~{count}', git_dir))
series.branch = branch or gitutil.get_branch()
series.top = top
return series
def prepare_patches(col, branch, count, start, end, ignore_binary, signoff,
- keep_change_id=False, cwd=None):
+ keep_change_id=False, git_dir=None, cwd=None):
"""Figure out what patches to generate, then generate them
The patch files are written to the current directory, e.g. 0001_xxx.patch
branch (str): Branch to create patches from (None = current)
count (int): Number of patches to produce, or -1 to produce patches for
the current branch back to the upstream commit
- start (int): Start partch to use (0=first / top of branch)
+ start (int): Start patch to use (0=first / top of branch)
end (int): End patch to use (0=last one in series, 1=one before that,
etc.)
ignore_binary (bool): Don't generate patches for binary files
keep_change_id (bool): Preserve the Change-Id tag.
+ git_dir (str): Path to git repository (None to use default)
cwd (str): Path to use for git operations (None to use current dir)
Returns:
"""
if count == -1:
# Work out how many patches to send if we can
- count = (gitutil.count_commits_to_branch(branch) - start)
+ count = (gitutil.count_commits_to_branch(branch, git_dir=git_dir) -
+ start)
if not count:
str = 'No commits found to process - please use -c flag, or run:\n' \
# Read the metadata from the commits
to_do = count - end
- series = patchstream.get_metadata(branch, start, to_do)
+ series = patchstream.get_metadata(branch, start, to_do, git_dir)
cover_fname, patch_files = gitutil.create_patches(
- branch, start, to_do, ignore_binary, series, signoff,
+ branch, start, to_do, ignore_binary, series, signoff, git_dir=git_dir,
cwd=cwd)
# Fix up the patch files to our liking, and insert the cover letter
return series, cover_fname, patch_files
-def send(args, cwd=None):
+def send(args, git_dir=None, cwd=None):
"""Create, check and send patches by email
Args:
series, cover_fname, patch_files = prepare_patches(
col, args.branch, args.count, args.start, args.end,
args.ignore_binary, args.add_signoff,
- keep_change_id=args.keep_change_id, cwd=cwd)
+ keep_change_id=args.keep_change_id, git_dir=git_dir, cwd=cwd)
ok = check_patches(series, patch_files, args.check_patch,
args.verbose, args.check_patch_use_tree, cwd)