Skip to content

Commit 9969712

Browse files
committed
update-download-data: accommodate for Git for Windows' four-part version format
Git for Windows' versions are usually based on upstream Git versions, and hence uses the same version string. Every once in a while, an extra version is required, in which case Git for Windows appends an extra number in parentheses, starting with 2 (implying that regular Git for Windows versions are implicitly "(1)"), at least where parentheses can be used (otherwise it appends it separated by a dot). Accommodate for such versions in the script that wants to update the download data. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent faa0a7a commit 9969712

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

script/update-download-data.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ def update_download_windows_versions(config)
3535
bitness = match[3]
3636

3737
# Git for windows sometimes creates extra releases all based off of the same upstream Git version
38-
# so we want to crop versions like 2.16.1.4 to just 2.16.1
38+
# so we first want to crop versions like 2.16.1.4 to just 2.16.1
3939
version = match[2].slice(/^\d+\.\d+\.\d+/)
40+
# Now, as per Git for Windows' custom, append the fourth part in parens, e.g. 2.16.1(4)
41+
version += "(#{match[2].slice(version.length + 1)})" if match[2][version.length] == "."
4042

4143
if version
4244
config["windows_installer"] = {} if config["windows_installer"].nil?
@@ -119,8 +121,8 @@ def files_from_sourceforge(repository)
119121
end
120122

121123
def version_compare(a, b)
122-
a = a.nil? ? [] : a.gsub(/^v/, "").split(/\./)
123-
b = b.nil? ? [] : b.gsub(/^v/, "").split(/\./)
124+
a = a.nil? ? [] : a.gsub(/^v/, "").split(/[.()]/)
125+
b = b.nil? ? [] : b.gsub(/^v/, "").split(/[.()]/)
124126
while true
125127
a0 = a.shift
126128
b0 = b.shift

0 commit comments

Comments
 (0)