Skip to content

Commit b564ee6

Browse files
committed
[Rolling Release Update] Find common tag between branches
Initially the assumption was that an update would be on the same base branch, like Rocky8_10 however in Rocky9_5 it will eventually transition to Rocky9_6 which will not have the same base RESF tag.
1 parent 7dd27be commit b564ee6

File tree

1 file changed

+40
-23
lines changed

1 file changed

+40
-23
lines changed

rolling-release-update.py

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,54 @@
55
import re
66
import git
77

8+
def find_common_tag(old_tags, new_tags):
9+
for tag in old_tags:
10+
if tag in new_tags:
11+
return tag
12+
return None
13+
14+
def get_branch_tag_sha_list(repo, branch):
15+
print('[rolling release update] Checking out branch: ', branch)
16+
repo.git.checkout(branch)
17+
results = subprocess.run(['git', 'log', '--decorate', '--oneline'], stderr=subprocess.PIPE, stdout=subprocess.PIPE,
18+
cwd=repo.working_dir)
19+
if results.returncode != 0:
20+
print(results.stderr)
21+
exit(1)
22+
23+
print('[rolling release update] Gathering all the RESF kernel Tags')
24+
tags = []
25+
for line in results.stdout.split(b'\n'):
26+
if b'tag: resf_kernel' in line:
27+
print(line)
28+
tags.append(line.split(b' ')[0])
29+
return tags
30+
831
if __name__ == '__main__':
932
parser = argparse.ArgumentParser(description='Rolling release update')
1033
parser.add_argument('--repo', help='Repository path', required=True)
1134
parser.add_argument('--new-base-branch', help='Branch name', required=True)
1235
parser.add_argument('--old-rolling-branch', help='Branch name for old rolling release: ex: sig-cloud-8/4.18.0-553.33.1.el8_10', required=True)
1336
args = parser.parse_args()
1437

38+
repo = git.Repo(args.repo)
1539

1640
rolling_product = args.old_rolling_branch.split('/')[0]
1741
print('[rolling release update] Rolling Product: ', rolling_product)
1842

19-
repo = git.Repo(args.repo)
20-
print('[rolling release update] Checking out old Rolling Branch: ', args.old_rolling_branch)
21-
repo.git.checkout(args.old_rolling_branch)
22-
print('[rolling release update] Finding the last resf_kernel tag the rolling release was based')
23-
results = subprocess.run(['git', 'log', '--decorate', '--oneline'], stderr=subprocess.PIPE, stdout=subprocess.PIPE,
24-
cwd=args.repo)
25-
if results.returncode != 0:
26-
print(results.stderr)
27-
exit(1)
28-
latest_resf_sha = ''
29-
for line in results.stdout.split(b'\n'):
30-
if b'tag: resf_kernel' in line:
31-
print(line)
32-
latest_resf_sha = line.split(b' ')[0]
33-
break
34-
print('[rolling release update] Last RESF tag sha: ', latest_resf_sha)
43+
old_rolling_branch_tags = get_branch_tag_sha_list(repo, args.old_rolling_branch)
44+
print('[rolling release update] Old Rolling Branch Tags: ', old_rolling_branch_tags)
3545

46+
new_base_branch_tags = get_branch_tag_sha_list(repo, args.new_base_branch)
47+
print('[rolling release update] New Base Branch Tags: ', new_base_branch_tags)
48+
49+
latest_resf_sha = find_common_tag(old_rolling_branch_tags, new_base_branch_tags)
50+
print('[rolling release update] Latest RESF tag sha: ', latest_resf_sha)
51+
print(repo.git.show('--pretty="%H %s"', '-s', latest_resf_sha.decode()))
52+
53+
54+
print('[rolling release update] Checking out old rolling branch: ', args.old_rolling_branch)
55+
repo.git.checkout(args.old_rolling_branch)
3656
print('[rolling release update] Finding the CIQ Kernel and Associated Upstream commits between the last resf tag and HEAD')
3757
rolling_commit_map = {}
3858
rollint_commit_map_rev = {}
@@ -46,20 +66,17 @@
4666
rolling_commit_map[ciq_commit] = upstream_commit
4767
rollint_commit_map_rev[upstream_commit] = ciq_commit
4868

69+
print('[rolling release update] Last RESF tag sha: ', latest_resf_sha)
70+
4971
print('{ "CIQ COMMMIT" : "UPSTREAM COMMMIT" }')
5072
print(json.dumps(rolling_commit_map, indent=2))
5173

52-
5374
print('[rolling release update] Checking out new base branch: ', args.new_base_branch)
5475
repo.git.checkout(args.new_base_branch)
5576

56-
print('[rolling release update] Finding the new resf_kernel tag the rolling release is based')
5777
results = subprocess.run(['git', 'log', '--decorate', '--oneline'], stderr=subprocess.PIPE, stdout=subprocess.PIPE,
58-
cwd=args.repo)
59-
if results.returncode != 0:
60-
print(results.stderr)
61-
exit(1)
62-
78+
cwd=repo.working_dir)
79+
6380
print('[rolling release update] Finding the kernel version for the new rolling release')
6481
new_rolling_branch_kernel = ''
6582
for line in results.stdout.split(b'\n'):

0 commit comments

Comments
 (0)