forked from devcontainers/features
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.sh
More file actions
19 lines (16 loc) · 721 Bytes
/
Copy pathutils.sh
File metadata and controls
19 lines (16 loc) · 721 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
# Shared helper functions for git "install from source" test scenarios.
# Resolves the latest stable git version from GitHub
get_latest_git_version() {
curl -sSL -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/git/git/tags" \
| grep -oP '"name":\s*"v\K[0-9]+\.[0-9]+\.[0-9]+(?=")' \
| sort -rV \
| head -n 1
}
# Verifies the installed git version matches the latest stable version on GitHub
check_git_is_latest_version() {
local latest_version installed_version
latest_version="$(get_latest_git_version)"
installed_version="$(git --version | awk '{print $3}')"
[ -n "$latest_version" ] && [ "$installed_version" = "$latest_version" ]
}