Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement update channels to introduce release versioning (#293)
- Loading branch information
Showing
13 changed files
with
162 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
function omf.cli.channel | ||
switch (count $argv) | ||
case 0 | ||
omf.channel.get | ||
|
||
case 1 | ||
omf.channel.set $argv | ||
|
||
case '*' | ||
echo (omf::err)"Invalid number of arguments"(omf::off) 1^&2 | ||
omf help channel | ||
return $OMF_INVALID_ARG | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
function omf.cli.version | ||
echo "Oh My Fish! $OMF_VERSION" | ||
echo "Oh My Fish version "(omf.version) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function omf.channel.get | ||
# Check for an environment variable override. | ||
if set -q OMF_CHANNEL | ||
echo $OMF_CHANNEL | ||
return 0 | ||
end | ||
|
||
# Check the channel file. | ||
if test -f $OMF_CONFIG/channel | ||
read -l channel < $OMF_CONFIG/channel | ||
and echo $channel | ||
and return 0 | ||
end | ||
|
||
# Assume 'stable' if not specified. | ||
echo stable | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
function omf.channel.set -a name | ||
# If an argument is specified, set the update channel. | ||
if begin; test -z "$name"; or not contains -- $name stable dev; end | ||
echo (omf::err)"'$name' is not a valid channel."(omf::off) 1^&2 | ||
return 1 | ||
end | ||
|
||
echo $name > $OMF_CONFIG/channel | ||
echo "Update channel set to "(omf::em)"$name"(omf::off)"." | ||
echo "To switch to the latest $name version, run "(omf::em)"omf update"(omf::off)"." | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,44 @@ | ||
function omf.core.update | ||
omf.repo.pull $OMF_PATH | ||
# If on the stable channel, checkout the latest tag. | ||
if test (omf.channel.get) = stable | ||
# If the channel isn't explicitly set and we are currently tracking a branch instead of a version, the user probably | ||
# upgraded from an old version. Let them know that we will start updating to stable versions. | ||
if begin; not test -f $OMF_CONFIG/channel; and command git -C "$OMF_PATH" symbolic-ref -q HEAD > /dev/null; end | ||
set_color $fish_color_quote ^/dev/null; or set_color yellow --bold | ||
echo ">> You have been switched to the stable release channel of Oh My Fish." | ||
echo ">> To switch back to the development channel, run `omf channel dev`." | ||
set_color normal | ||
end | ||
|
||
# Determine the remote to fetch from. | ||
set -l remote origin | ||
if test (command git -C "$OMF_PATH" config --get remote.upstream.url) | ||
set remote upstream | ||
end | ||
|
||
# Fetch the latest tags. | ||
command git -C "$OMF_PATH" fetch --quiet --tags $remote | ||
# Get the commit for the latest release. | ||
and set -l hash (command git -C "$OMF_PATH" rev-list --tags='v*' --max-count=1 ^ /dev/null) | ||
# Get the release tag. | ||
and set -l tag (command git -C "$OMF_PATH" describe --tags $hash) | ||
# Checkout the release. | ||
and command git -C "$OMF_PATH" checkout --quiet tags/$tag | ||
and return 0 | ||
|
||
# Something went wrong. | ||
echo (omf::err)"No release versions found."(omf::off) | ||
return 1 | ||
else | ||
# Determine the branch to use for the dev channel. | ||
set -q OMF_DEV_BRANCH | ||
or set -l OMF_DEV_BRANCH master | ||
|
||
# Switch to the master branch if we are in a detached head. | ||
command git -C "$OMF_PATH" symbolic-ref -q HEAD > /dev/null | ||
or command git -C "$OMF_PATH" checkout $OMF_DEV_BRANCH --quiet | ||
|
||
# Pull the latest for the current branch. | ||
omf.repo.pull $OMF_PATH | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function omf.version | ||
command git -C "$OMF_PATH" describe --tags --match 'v*' --always | cut -c 2- | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters