Skip to content

Commit f02623d

Browse files
Support -e, --edit option for cherry-pick subcommand to specify edited commit message
Signed-off-by: Jacob Stopak <[email protected]>
1 parent e68e5e2 commit f02623d

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ Usage: `git-sim rebase <new-base>`
218218
Usage: `git-sim cherry-pick <commit>`
219219

220220
- Specify `<commit>` as a ref (branch name/tag) or commit ID to cherry-pick onto the active branch
221+
- Supports editing the cherry-picked commit message with: `$ git-sim cherry-pick <commit> -e "Edited commit message"`
221222

222223
![git-sim-cherry-pick_01-05-23_22-23-08](https://user-images.githubusercontent.com/49353917/210942811-fa5155b1-4c6f-4afc-bea2-d39b4cd594aa.jpg)
223224

git_sim/__main__.py

+6
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,12 @@ def main():
283283
type=str,
284284
help="The ref (branch/tag), or commit ID to simulate cherry-pick onto active branch",
285285
)
286+
cherrypick.add_argument(
287+
"-e",
288+
"--edit",
289+
help="Specify a new commit message for the cherry-picked commit",
290+
type=str,
291+
)
286292

287293
if len(sys.argv) == 1:
288294
parser.print_help()

git_sim/git_sim_cherrypick.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ def __init__(self, args: Namespace):
3030
pass
3131

3232
def construct(self):
33-
print("Simulating: git " + self.args.subcommand + " " + self.args.commit[0])
33+
print(
34+
"Simulating: git "
35+
+ self.args.subcommand
36+
+ " "
37+
+ self.args.commit[0]
38+
+ ((' -e "' + self.args.edit + '"') if self.args.edit else "")
39+
)
3440

3541
if self.repo.active_branch.name in self.repo.git.branch(
3642
"--contains", self.args.commit[0]
@@ -51,7 +57,10 @@ def construct(self):
5157
self.get_commits(start=self.args.commit[0])
5258
self.parse_commits(self.commits[0], shift=4 * m.DOWN)
5359
self.center_frame_on_commit(self.orig_commits[0])
54-
self.setup_and_draw_parent(self.orig_commits[0], self.commits[0].message)
60+
self.setup_and_draw_parent(
61+
self.orig_commits[0],
62+
self.args.edit if self.args.edit else self.commits[0].message,
63+
)
5564
self.draw_arrow_between_commits(self.commits[0].hexsha, "abcdef")
5665
self.recenter_frame()
5766
self.scale_frame()

0 commit comments

Comments
 (0)