Skip to content

Commit 14a2542

Browse files
committed
moving code to derive stable branch name into a function
1 parent e12bbdd commit 14a2542

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

script/release

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -343,19 +343,26 @@ def is_base_branch_valid?(branch)
343343
end
344344
end
345345

346+
def get_stable_branch_name(branch)
347+
## derive the proper stable branch. if the base branch is "master" the stable branch is just "stable"
348+
## if the base branch is a release branch, the stable branch will be "x.y-stable"
349+
result = ""
350+
if branch == "master"
351+
result = "stable"
352+
else
353+
result = branch.gsub(/-main$/, "-stable")
354+
end
355+
356+
result
357+
end
358+
346359
#### All the action starts ####
347360
if $PROGRAM_NAME == __FILE__
348361
begin
349362
## validate base branch. this must either be "master" or a release branch which will match the pattern "x.y-main"
350363
raise "The branch #{GH_BASE_BRANCH} is not valid for releasing backup-utils. branch name must be master or match x.y-main" if !is_base_branch_valid?(GH_BASE_BRANCH)
351364

352-
## derive the proper stable branch. if the base branch is "master" the stable branch is just "stable"
353-
## if the base branch is a release branch, the stable branch will be "x.y-stable"
354-
if GH_BASE_BRANCH == "master"
355-
GH_STABLE_BRANCH = "stable"
356-
else
357-
GH_STABLE_BRANCH = GH_BASE_BRANCH.gsub(/-main$/, "-stable")
358-
end
365+
GH_STABLE_BRANCH = get_stable_branch_name(GH_BASE_BRANCH)
359366

360367
puts "base branch = " + GH_BASE_BRANCH
361368
puts "stable branch = " + GH_STABLE_BRANCH

0 commit comments

Comments
 (0)