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
7a2cb106
Unverified
Commit
7a2cb106
authored
Nov 05, 2021
by
Marc Cornellà
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(updater): stop update if connection unavailable
parent
0520c2e3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
6 deletions
+19
-6
check_for_upgrade.sh
tools/check_for_upgrade.sh
+19
-6
No files found.
tools/check_for_upgrade.sh
View file @
7a2cb106
...
@@ -54,14 +54,27 @@ function is_update_available() {
...
@@ -54,14 +54,27 @@ function is_update_available() {
[[
"
$repo
"
=
ohmyzsh/ohmyzsh
]]
||
return
0
[[
"
$repo
"
=
ohmyzsh/ohmyzsh
]]
||
return
0
local
api_url
=
"https://api.github.com/repos/
${
repo
}
/commits/
${
branch
}
"
local
api_url
=
"https://api.github.com/repos/
${
repo
}
/commits/
${
branch
}
"
# Get local
and remote HEADs and compare them. If we can't get either
assume there are updates
# Get local
HEAD. If this fails
assume there are updates
local
local_head
remote_head
local
local_head
local_head
=
$(
git
-C
"
$ZSH
"
rev-parse
$branch
2>/dev/null
)
||
return
0
local_head
=
$(
git
-C
"
$ZSH
"
rev-parse
$branch
2>/dev/null
)
||
return
0
remote_head
=
$(
curl
-fsSL
-H
'Accept: application/vnd.github.v3.sha'
$api_url
2>/dev/null
)
\
# Get remote HEAD. If we can't get it assume there are updates unless there is no connection:
||
remote_head
=
$(
wget
-O-
--header
=
'Accept: application/vnd.github.v3.sha'
$api_url
2>/dev/null
)
\
# - curl: 6 (could not resolve) or 7 (could not connect)
||
remote_head
=
$(
HTTP_ACCEPT
=
'Accept: application/vnd.github.v3.sha'
fetch
-o
-
$api_url
2>/dev/null
)
\
# - wget: 4 (network unreachable)
||
return
0
# - fetch: 1 (no route to host)
local
remote_head ret
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
# Compare local and remote HEADs
# Compare local and remote HEADs
[[
"
$local_head
"
!=
"
$remote_head
"
]]
[[
"
$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