File tree Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ def main(
1414 sh : ghstack .shell .Shell ,
1515 remote_name : str ,
1616 stack : bool = False ,
17+ keep_redundant_commits : bool = False ,
1718) -> None :
1819
1920 params = ghstack .github_utils .parse_pull_request (
@@ -56,10 +57,18 @@ def main(
5657
5758 logging .info (f"Cherry-picking { len (commit_list )} commits from stack" )
5859 for commit in commit_list :
59- sh .git ("cherry-pick" , commit )
60+ args = ["cherry-pick" ]
61+ if keep_redundant_commits :
62+ args .append ("--keep-redundant-commits" )
63+ args .append (commit )
64+ sh .git (* args )
6065 logging .info (f"Cherry-picked { commit } " )
6166 else :
6267 # Cherry-pick just the single commit
6368 remote_orig_ref = remote_name + "/" + orig_ref
64- sh .git ("cherry-pick" , remote_orig_ref )
69+ args = ["cherry-pick" ]
70+ if keep_redundant_commits :
71+ args .append ("--keep-redundant-commits" )
72+ args .append (remote_orig_ref )
73+ sh .git (* args )
6574 logging .info (f"Cherry-picked { orig_ref } " )
Original file line number Diff line number Diff line change @@ -134,8 +134,13 @@ def checkout(pull_request: str) -> None:
134134 is_flag = True ,
135135 help = "Cherry-pick all commits from the commit to the merge-base with main branch" ,
136136)
137+ @click .option (
138+ "--keep-redundant-commits" ,
139+ is_flag = True ,
140+ help = "Keep redundant commits when cherry-picking (passed to git cherry-pick)" ,
141+ )
137142@click .argument ("pull_request" , metavar = "PR" )
138- def cherry_pick (stack : bool , pull_request : str ) -> None :
143+ def cherry_pick (stack : bool , keep_redundant_commits : bool , pull_request : str ) -> None :
139144 """
140145 Cherry-pick a PR
141146 """
@@ -146,6 +151,7 @@ def cherry_pick(stack: bool, pull_request: str) -> None:
146151 sh = shell ,
147152 remote_name = config .remote_name ,
148153 stack = stack ,
154+ keep_redundant_commits = keep_redundant_commits ,
149155 )
150156
151157
Original file line number Diff line number Diff line change @@ -240,14 +240,15 @@ def gh_unlink() -> None:
240240 )
241241
242242
243- def gh_cherry_pick (pull_request : str , stack : bool = False ) -> None :
243+ def gh_cherry_pick (pull_request : str , stack : bool = False , keep_redundant_commits : bool = False ) -> None :
244244 self = CTX
245245 return ghstack .cherry_pick .main (
246246 pull_request = pull_request ,
247247 github = self .github ,
248248 sh = self .sh ,
249249 remote_name = "origin" ,
250250 stack = stack ,
251+ keep_redundant_commits = keep_redundant_commits ,
251252 )
252253
253254
You can’t perform that action at this time.
0 commit comments