Skip to content

Commit 5465161

Browse files
authored
Merge pull request #4210 from anyproto/ios-2532-fix-comment-version-for-hotfix
IOS-2532 Fix Linear comment version diff for hotfix releases
2 parents ab492c9 + 019fa3e commit 5465161

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

fastlane/FastfileDeploy

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,31 @@ platform :ios do
9999
sh("git push origin refs/tags/#{tag_name} --no-verify --force")
100100

101101
appInfo = settings[:app_info]
102-
old_tag_name = sh("git describe --first-parent --tags --abbrev=0 HEAD~").chomp
102+
103+
# Determine the previous tag to use for diff generation in Linear comments
104+
# This ensures hotfix releases (e.g., 0.41.1) correctly diff against the last build
105+
# of the previous version (0.41.0/27) instead of finding an old tag from a different branch
106+
if build_number.to_i > 1
107+
# For incremental builds (e.g., 0.41.0/26 -> 0.41.0/27), use the previous build number
108+
old_tag_name = "#{prefix}/#{version}/#{build_number.to_i - 1}"
109+
else
110+
# For the first build of a new version (e.g., 0.41.1/1), find the last tag of the previous patch version
111+
# Get major.minor version (e.g., "0.41" from "0.41.1")
112+
version_parts = version.split('.')
113+
major_minor = "#{version_parts[0]}.#{version_parts[1]}"
114+
current_patch = version_parts[2].to_i
115+
116+
# Get all tags for the current major.minor (e.g., all 0.41.x tags), sorted by version
117+
all_version_tags = sh("git tag -l '#{prefix}/#{major_minor}.*/*' | sort -V").split("\n")
118+
119+
# Find tags for versions less than current patch, take the last one
120+
previous_version_tags = all_version_tags.select do |t|
121+
tag_patch = t.match(/#{Regexp.escape(prefix)}\/#{Regexp.escape(major_minor)}\.(\d+)\//)
122+
tag_patch && tag_patch[1].to_i < current_patch
123+
end
124+
125+
old_tag_name = previous_version_tags.last || tag_name
126+
end
103127

104128
add_linear_comment(
105129
from_tag: old_tag_name,

0 commit comments

Comments
 (0)