Skip to content

Include 'name' in squash's edit message. #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions stgit/commands/squash.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def _strip_comments(message):
yield line


def _squash_patches(trans, patches, msg, save_template, no_verify=False):
def _squash_patches(trans, patches, name, msg, save_template, no_verify=False):
cd = trans.patches[patches[0]].data
for pn in patches[1:]:
c = trans.patches[pn]
Expand All @@ -80,7 +80,10 @@ def _squash_patches(trans, patches, msg, save_template, no_verify=False):
return None
cd = cd.set_tree(tree)
if msg is None:
msg = "# This is a combination of %s patches.\n" % len(patches)
if name:
msg = "# Squashing %s patches as '%s'.\n" % (len(patches), name)
else:
msg = "# Squashing %s patches.\n" % len(patches)
for num, pn in enumerate(patches, 1):
msg += "# This is the commit message for %s (patch #%s):" % (
pn,
Expand Down Expand Up @@ -122,7 +125,9 @@ def make_squashed_patch(trans, new_commit_data):
trans = StackTransaction(stack, 'squash', allow_conflicts=True)
push_new_patch = bool(set(patches) & set(trans.applied))
try:
new_commit_data = _squash_patches(trans, patches, msg, save_template, no_verify)
new_commit_data = _squash_patches(
trans, patches, name, msg, save_template, no_verify
)
if new_commit_data:
# We were able to construct the squashed commit
# automatically. So just delete its constituent patches.
Expand All @@ -135,7 +140,7 @@ def make_squashed_patch(trans, new_commit_data):
for pn in patches:
trans.push_patch(pn, iw)
new_commit_data = _squash_patches(
trans, patches, msg, save_template, no_verify
trans, patches, name, msg, save_template, no_verify
)
popped_extra = trans.delete_patches(lambda pn: pn in patches)
assert not popped_extra
Expand Down