Lines Matching +full:cherry +full:- +full:pick
5 # This source code is licensed under the BSD-style license found in the
11 pick_doc_commits.py --main=origin/main --release=origin/release/5.5
14 filter them down to the docs-only commits that should be cherrypicked. It will
34 # Controlled by the --verbose flag.
45 def run_git(command: List[str]) -> List[str]:
54 A list of the non-empty lines printed to stdout, without trailing
66 # Remove empty and whitespace-only lines.
70 debug_log("-----BEGIN GIT OUTPUT-----")
73 debug_log("-----END GIT OUTPUT-----")
80 """A git commit hash and its one-line message."""
87 message: The one-line summary of the commit. If empty, this method
93 lines = run_git(["log", "-1", "--pretty=%s", self.hash])
99 def from_line(line: str) -> "Commit":
113 def is_doc_only_commit(commit: Commit) -> bool:
116 def is_doc_file(path: str) -> bool:
128 lines = run_git(["diff-tree", "--name-only", "-r", commit.hash])
131 non_doc_files = all_files - doc_files
136 f"{repr(commit)} touches {len(non_doc_files)} non-doc files, "
143 def print_wrapped(text: str, width: int = 80) -> None:
148 print("\n ".join(textwrap.wrap(text, width=width - 4, break_on_hyphens=False)))
151 def parse_args() -> argparse.Namespace:
156 "--main",
159 help="The name of the main (source) branch to pick commits from.",
162 "--release",
164 help="The name of the release (destination) branch to pick commits onto, "
168 "-v",
169 "--verbose",
172 help="Log extra output. Specify more times (-vv) for more output.",
186 # branch. Each hash is preceded by `+ ` if the commit has not been cherry
187 # picked onto the release branch, or `- ` if it has.
188 cherry_lines = run_git(["cherry", release_branch, main_branch])
190 f"Commits on '{main_branch}' that have already been cherry-picked into '{release_branch}':"
193 print("- <none>")
199 elif line.startswith("- "):
200 print(f"- {commit}")
203 # Filter out and print the commits that touch non-documentation files.
205 f"Will not pick these commits on '{main_branch}' that touch non-documentation files:"
208 print("- <none>")
214 print(f"- {commit}")
217 # Print the commits to cherry-pick.
220 + f"will be cherry-picked into '{release_branch}':"
223 print("- <none>")
225 print(f"- {commit}")
228 # Print instructions for cherry-picking the commits.
232 branch_name = "cherrypick-" + release_branch.replace("/", "-") + "-" + suffix
234 print("Cherry pick by running the commands:")
239 # still copy-pasteable.
240 "git cherry-pick \\\n "
243 print(f"git checkout -b {branch_name}")
246 print("To verify that this worked, re-run this script with the arguments:")
248 print(f"--main={main_branch} --release={branch_name}")
250 print("It should show no doc-only commits to cherry-pick.")
254 print(f"git push --set-upstream origin {branch_name}")
265 "It looks like there are no doc-only commits "
266 + f"on '{main_branch}' to cherry-pick into '{release_branch}'."