Skip to content

Commit 181493c

Browse files
committed
IOS-2532 Fix Linear comment version diff for hotfix releases
Replace git describe with intelligent tag parsing to ensure hotfix releases correctly diff against the previous version. Previously, hotfix releases would find old tags from merged branches, causing large diffs and notifying many unrelated Linear issues.
1 parent cf7b6ab commit 181493c

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

fastlane/FastfileDeploy

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,23 @@ 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 version
111+
# Get all tags for the current major version (e.g., all 0.41.x tags), sorted by version
112+
all_version_tags = sh("git tag -l '#{prefix}/#{version.split('.')[0]}.*/*' | sort -V").split("\n")
113+
114+
# Find the index of the current version in the sorted list
115+
current_idx = all_version_tags.index { |t| t.start_with?("#{prefix}/#{version}/") }
116+
# Use the tag immediately before the current version, or fallback to current tag if not found
117+
old_tag_name = current_idx && current_idx > 0 ? all_version_tags[current_idx - 1] : tag_name
118+
end
103119

104120
add_linear_comment(
105121
from_tag: old_tag_name,

0 commit comments

Comments
 (0)