Skip to content

Commit 23fc86c

Browse files
authored
Merge pull request #338 from dscho/update-from-fork
git update-git-for-windows: optionally update from a fork
2 parents 5e4278f + a7033b6 commit 23fc86c

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

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

+23-5
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,26 @@ update_git_for_windows () {
174174
;;
175175
esac
176176

177-
latest_tag_url=https://gitforwindows.org/latest-tag.txt
177+
test -f "$0.config" &&
178+
fork="$(git config -f "$0.config" update.fromFork)" &&
179+
test -n "$fork" ||
180+
fork=
181+
182+
if test -n "$fork"
183+
then
184+
git_label="$(git config -f "$0.config" update.gitLabel)"
185+
test -n "$git_label" || git_label=Git
186+
187+
releases_url=https://api.github.com/repos/$fork/releases
188+
latest_tag_url=$releases_url/latest
189+
latest_eval='latest=${latest_tag#*\"tag_name\": \"}; latest=${latest%%\"*}'
190+
else
191+
git_label="Git for Windows"
192+
releases_url=https://api.github.com/repos/git-for-windows/git/releases
193+
latest_tag_url=https://gitforwindows.org/latest-tag.txt
194+
latest_eval='latest=${latest_tag#v}'
195+
fi
196+
178197
latest_tag=$(http_get $latest_tag_url) ||
179198
case $?,"$proxy" in
180199
7,)
@@ -190,13 +209,13 @@ update_git_for_windows () {
190209
;;
191210
esac
192211

193-
latest=${latest_tag#v}
212+
eval "$latest_eval"
194213
# Did we ask about this version already?
195214
recently_seen="$(get_recently_seen)"
196215
test -n "$quiet" && test "x$recently_seen" = "x$latest" && return
197216

198217
version=$(git --version | sed "s/git version //")
199-
echo "Git for Windows $version (${bit}bit)" >&2
218+
echo "$git_label $version (${bit}bit)" >&2
200219
if test -z "$testing" && test "$latest" = "$version"
201220
then
202221
echo "Up to date" >&2
@@ -215,7 +234,6 @@ update_git_for_windows () {
215234
esac
216235

217236
echo "Update $latest is available" >&2
218-
releases_url=https://api.github.com/repos/git-for-windows/git/releases
219237
releases=$(http_get $releases_url/latest) || return
220238
download=$(echo "$releases" |
221239
grep '"browser_download_url": "' |
@@ -238,7 +256,7 @@ update_git_for_windows () {
238256
fi
239257
if test -n "$try_toast"
240258
then
241-
wintoast.exe --appname "Git for Windows" \
259+
wintoast.exe --appname "$git_label" \
242260
--appid GitForWindows.Updater \
243261
--image /mingw$bit/share/git/git-for-windows.ico \
244262
--text "Download and install $name$warn?" \

0 commit comments

Comments
 (0)