Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
db19589f
Unverified
Commit
db19589f
authored
Nov 09, 2021
by
Marc Cornellà
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(updater): simplify check for available updates
parent
5c2440cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
16 deletions
+13
-16
check_for_upgrade.sh
tools/check_for_upgrade.sh
+13
-16
No files found.
tools/check_for_upgrade.sh
View file @
db19589f
...
...
@@ -58,23 +58,20 @@ function is_update_available() {
local
local_head
local_head
=
$(
git
-C
"
$ZSH
"
rev-parse
$branch
2>/dev/null
)
||
return
0
# Get remote HEAD. If we can't get it assume there are updates unless there is no connection:
# - curl: 6 (could not resolve) or 7 (could not connect)
# - wget: 4 (network unreachable)
# - fetch: 1 (no route to host)
local
remote_head ret
# Get remote HEAD. If no suitable command is found assume there are updates
# On any other error, skip the update (connection may be down)
local
remote_head
remote_head
=
$(
curl
-fsSL
-H
'Accept: application/vnd.github.v3.sha'
$api_url
2>/dev/null
||
{
[[
$?
-eq
6
||
$?
-eq
7
]]
&&
exit
1
}
||
wget
-O-
--header
=
'Accept: application/vnd.github.v3.sha'
$api_url
2>/dev/null
||
{
[[
$?
-eq
4
]]
&&
exit
1
}
||
HTTP_ACCEPT
=
'Accept: application/vnd.github.v3.sha'
fetch
-o
-
$api_url
2>/dev/null
||
{
[[
$?
-eq
1
]]
&&
exit
1
}
||
exit
0
)
# If can't fetch remote HEAD, return exit code
ret
=
$?
;
[[
-n
"
$remote_head
"
]]
||
return
$ret
if
((
${
+commands[curl]
}
)
)
;
then
curl
-fsSL
-H
'Accept: application/vnd.github.v3.sha'
$api_url
2>/dev/null
elif
((
${
+commands[wget]
}
))
;
then
wget
-O-
--header
=
'Accept: application/vnd.github.v3.sha'
$api_url
2>/dev/null
elif
((
${
+commands[fetch]
}
))
;
then
HTTP_ACCEPT
=
'Accept: application/vnd.github.v3.sha'
fetch
-o
-
$api_url
2>/dev/null
else
exit
0
fi
)
||
return
1
# Compare local and remote HEADs
[[
"
$local_head
"
!=
"
$remote_head
"
]]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment