Skip to content

Commit f4486be

Browse files
committed
ciq-cherry-pick.py: Ruff formatting
This was done automatically by ruff format. Default configuration is used. Signed-off-by: Roxana Nicolescu <rnicolescu@ciq.com>
1 parent 2746af6 commit f4486be

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ repos:
1111

1212
exclude: |
1313
(?x)^(
14-
ciq-cherry-pick.py |
1514
ciq_helpers.py |
1615
jira_pr_check.py |
1716
release_config.py |

ciq-cherry-pick.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,49 @@
11
import argparse
22
import os
33
import subprocess
4+
45
import git
5-
from ciq_helpers import CIQ_cherry_pick_commit_standardization
6-
from ciq_helpers import CIQ_original_commit_author_to_tag_string
6+
7+
from ciq_helpers import CIQ_cherry_pick_commit_standardization, CIQ_original_commit_author_to_tag_string
8+
79
# from ciq_helpers import *
810

9-
MERGE_MSG = git.Repo(os.getcwd()).git_dir + '/MERGE_MSG'
11+
MERGE_MSG = git.Repo(os.getcwd()).git_dir + "/MERGE_MSG"
1012

11-
if __name__ == '__main__':
13+
if __name__ == "__main__":
1214
print("CIQ custom cherry picker")
1315
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
14-
parser.add_argument('--sha', help='Target SHA1 to cherry-pick')
15-
parser.add_argument('--ticket', help='Ticket associated to cherry-pick work, comma separated list is supported.')
16-
parser.add_argument('--ciq-tag', help="Tags for commit message <feature><-optional modifier> <identifier>.\n"
17-
"example: cve CVE-2022-45884 - A patch for a CVE Fix.\n"
18-
" cve-bf CVE-1974-0001 - A bug fix for a CVE currently being patched\n"
19-
" cve-pre CVE-1974-0001 - A pre-condition or dependency needed for the CVE\n"
20-
"Multiple tags are separated with a comma. ex: cve CVE-1974-0001, cve CVE-1974-0002\n")
16+
parser.add_argument("--sha", help="Target SHA1 to cherry-pick")
17+
parser.add_argument("--ticket", help="Ticket associated to cherry-pick work, comma separated list is supported.")
18+
parser.add_argument(
19+
"--ciq-tag",
20+
help="Tags for commit message <feature><-optional modifier> <identifier>.\n"
21+
"example: cve CVE-2022-45884 - A patch for a CVE Fix.\n"
22+
" cve-bf CVE-1974-0001 - A bug fix for a CVE currently being patched\n"
23+
" cve-pre CVE-1974-0001 - A pre-condition or dependency needed for the CVE\n"
24+
"Multiple tags are separated with a comma. ex: cve CVE-1974-0001, cve CVE-1974-0002\n",
25+
)
2126
args = parser.parse_args()
2227

2328
# Expand the provided SHA1 to the full SHA1 in case it's either abbreviated or an expression
24-
git_sha_res = subprocess.run(['git', 'show', '--pretty=%H', '-s', args.sha], stdout=subprocess.PIPE)
29+
git_sha_res = subprocess.run(["git", "show", "--pretty=%H", "-s", args.sha], stdout=subprocess.PIPE)
2530
if git_sha_res.returncode != 0:
2631
print(f"[FAILED] git show --pretty=%H -s {args.sha}")
2732
print("Subprocess Call:")
2833
print(git_sha_res)
2934
print("")
3035
else:
31-
args.sha = git_sha_res.stdout.decode('utf-8').strip()
36+
args.sha = git_sha_res.stdout.decode("utf-8").strip()
3237

3338
tags = []
3439
if args.ciq_tag is not None:
35-
tags = args.ciq_tag.split(',')
40+
tags = args.ciq_tag.split(",")
3641

3742
author = CIQ_original_commit_author_to_tag_string(repo_path=os.getcwd(), sha=args.sha)
3843
if author is None:
3944
exit(1)
4045

41-
git_res = subprocess.run(['git', 'cherry-pick', '-nsx', args.sha])
46+
git_res = subprocess.run(["git", "cherry-pick", "-nsx", args.sha])
4247
if git_res.returncode != 0:
4348
print(f"[FAILED] git cherry-pick -nsx {args.sha}")
4449
print(" Manually resolve conflict and include `upstream-diff` tag in commit message")
@@ -47,7 +52,7 @@
4752
print("")
4853

4954
print(os.getcwd())
50-
subprocess.run(['cp', MERGE_MSG, f'{MERGE_MSG}.bak'])
55+
subprocess.run(["cp", MERGE_MSG, f"{MERGE_MSG}.bak"])
5156

5257
tags.append(author)
5358

@@ -58,11 +63,11 @@
5863

5964
print(f"Cherry Pick New Message for {args.sha}")
6065
for line in new_msg:
61-
print(line.strip('\n'))
66+
print(line.strip("\n"))
6267
print(f"\n Original Message located here: {MERGE_MSG}.bak")
6368

6469
with open(MERGE_MSG, "w") as file:
6570
file.writelines(new_msg)
6671

6772
if git_res.returncode == 0:
68-
subprocess.run(['git', 'commit', '-F', MERGE_MSG])
73+
subprocess.run(["git", "commit", "-F", MERGE_MSG])

0 commit comments

Comments
 (0)