Skip to content

Commit 372bf44

Browse files
committed
git update-git-for-windows: optionally update from a fork
For the upcoming ARM64 support, as well as for the Microsoft fork of Git for Windows, it would be helpful if there was a way to update from the GitHub Releases of the respective fork instead of Git for Windows' own fork. To facilitate that, let's introduce support for a `git-update-git-for-windows.config` file next to the script: if it exists, treat it as a Git config file and read the `update.fromFork` value, and then continue with that value inserted into the URL https://github.com/<fork>/releases. Example: to ask the updater to look for new versions at https://github.com/dennisameling/git/releases, run the following command as administrator: git config \ -f "$(git --exec-path)/git-update-git-for-windows.config" \ update.fromFork dennisameling/git Signed-off-by: Johannes Schindelin <[email protected]>
1 parent f95524e commit 372bf44

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

git-extra/git-update-git-for-windows

+17-3
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,22 @@ update_git_for_windows () {
174174
;;
175175
esac
176176

177-
latest_tag_url=https://gitforwindows.org/latest-tag.txt
177+
if test -f "$0.config"
178+
then
179+
fork="$(git config -f "$0.config" update.fromFork)"
180+
test -n "$fork" || {
181+
echo "Could not find update.fromFork in $0.config" >&2
182+
return 1
183+
}
184+
releases_url=https://api.github.com/repos/$fork/releases
185+
latest_tag_url=$releases_url/latest
186+
latest_eval='latest=${latest_tag#*\"tag_name\": \"}; latest=${latest%%\"*}'
187+
else
188+
releases_url=https://api.github.com/repos/git-for-windows/git/releases
189+
latest_tag_url=https://gitforwindows.org/latest-tag.txt
190+
latest_eval='latest=${latest_tag#v}'
191+
fi
192+
178193
latest_tag=$(http_get $latest_tag_url) ||
179194
case $?,"$proxy" in
180195
7,)
@@ -190,7 +205,7 @@ update_git_for_windows () {
190205
;;
191206
esac
192207

193-
latest=${latest_tag#v}
208+
eval "$latest_eval"
194209
# Did we ask about this version already?
195210
recently_seen="$(get_recently_seen)"
196211
test -n "$quiet" && test "x$recently_seen" = "x$latest" && return
@@ -215,7 +230,6 @@ update_git_for_windows () {
215230
esac
216231

217232
echo "Update $latest is available" >&2
218-
releases_url=https://api.github.com/repos/git-for-windows/git/releases
219233
releases=$(http_get $releases_url/latest) || return
220234
download=$(echo "$releases" |
221235
grep '"browser_download_url": "' |

0 commit comments

Comments
 (0)