mirror of https://git.envs.net/envs/burrow.git
added update-burrow action
This commit is contained in:
parent
f41090af3e
commit
39372f1d0c
|
@ -46,6 +46,7 @@ burrow topic # add or update a topic file
|
||||||
burrow create-config # generate a default config file
|
burrow create-config # generate a default config file
|
||||||
burrow edit-config # open your config file for editing
|
burrow edit-config # open your config file for editing
|
||||||
burrow update-git # pull latest git repo for gopher dir, if exists
|
burrow update-git # pull latest git repo for gopher dir, if exists
|
||||||
|
burrow update-burrow # update git repo or pull latest version from github
|
||||||
```
|
```
|
||||||
|
|
||||||
- `create-config` will auto-generate a configuration file at
|
- `create-config` will auto-generate a configuration file at
|
||||||
|
@ -71,6 +72,11 @@ by including a `.template` file in your topics directory.
|
||||||
- `update-git` will silently attempt to update a git repository at the location
|
- `update-git` will silently attempt to update a git repository at the location
|
||||||
of your gopher hole. It is appropriate for use by a cron job.
|
of your gopher hole. It is appropriate for use by a cron job.
|
||||||
|
|
||||||
|
- `update-burrow` will attempt to pull the latest version of burrow from git if
|
||||||
|
your local folder is a git repository. If not, it will attempt to update each
|
||||||
|
file in the burrow directory with the same named file in the master branch of
|
||||||
|
the git repository for burrow on Github.
|
||||||
|
|
||||||
_`man burrow` or `burrow -h` for more information._
|
_`man burrow` or `burrow -h` for more information._
|
||||||
|
|
||||||
## Config
|
## Config
|
||||||
|
|
43
burrow
43
burrow
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
version="v1.2.5"
|
version="v1.2.6"
|
||||||
|
|
||||||
shopt -s extglob
|
shopt -s extglob
|
||||||
configfiles="$HOME/.config/burrow/config $HOME/.config/burrow $HOME/.burrow"
|
configfiles="$HOME/.config/burrow/config $HOME/.config/burrow $HOME/.burrow"
|
||||||
|
@ -42,6 +42,7 @@ arg_topic=0
|
||||||
arg_create_config=0
|
arg_create_config=0
|
||||||
arg_edit_config=0
|
arg_edit_config=0
|
||||||
arg_update_git=0
|
arg_update_git=0
|
||||||
|
arg_update_burrow=0
|
||||||
|
|
||||||
# silence directory movements
|
# silence directory movements
|
||||||
pushd () {
|
pushd () {
|
||||||
|
@ -63,6 +64,7 @@ COMMANDS:
|
||||||
create-config Create a default configuration file
|
create-config Create a default configuration file
|
||||||
edit-config Edit your configuration file
|
edit-config Edit your configuration file
|
||||||
update-git Silently pulls gopher git repo if it exists
|
update-git Silently pulls gopher git repo if it exists
|
||||||
|
update-burrow Auto-update this application in its local folder
|
||||||
|
|
||||||
OPTIONAL FLAGS:
|
OPTIONAL FLAGS:
|
||||||
-h, --help Show this help
|
-h, --help Show this help
|
||||||
|
@ -130,6 +132,7 @@ function parse_input {
|
||||||
"create-config") arg_create_config=1 ;;
|
"create-config") arg_create_config=1 ;;
|
||||||
"edit-config") arg_edit_config=1 ;;
|
"edit-config") arg_edit_config=1 ;;
|
||||||
"update-git") arg_update_git=1 ;;
|
"update-git") arg_update_git=1 ;;
|
||||||
|
"update-burrow") arg_update_burrow=1 ;;
|
||||||
*) echo "Unknown command: $arg";;
|
*) echo "Unknown command: $arg";;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
@ -397,11 +400,43 @@ function update_git {
|
||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function update_burrow {
|
||||||
|
burrow_src="${BASH_SOURCE[0]}"
|
||||||
|
while [ -h "${burrow_src}" ]; do
|
||||||
|
burrow_dir="$( cd -P "$( dirname "${burrow_src}" )" && pwd )"
|
||||||
|
burrow_src="$(readlink "${burrow_src}")"
|
||||||
|
[[ ${burrow_src} != /* ]] && burrow_src="${burrow_dir}/${burrow_src}"
|
||||||
|
done
|
||||||
|
burrow_dir="$( cd -P "$( dirname "${burrow_src}" )" && pwd )"
|
||||||
|
pushd "${burrow_dir}"
|
||||||
|
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) ]]; then
|
||||||
|
read -r -p "Do you want to update your burrow git repository? [y/N] " response
|
||||||
|
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]
|
||||||
|
then
|
||||||
|
git pull -q
|
||||||
|
else
|
||||||
|
die "Aborting." 0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
github_src="https://raw.githubusercontent.com/jamestomasino/burrow/master/"
|
||||||
|
read -r -p "Do you want to fetch the latest burrow executable? [y/N] " response
|
||||||
|
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]
|
||||||
|
then
|
||||||
|
for filename in ./burrow*; do
|
||||||
|
curl -sfLO "${github_src}${filename}"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
die "Aborting." 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
popd
|
||||||
|
}
|
||||||
|
|
||||||
function main {
|
function main {
|
||||||
parse_input "$@"
|
parse_input "$@"
|
||||||
|
|
||||||
if [[ $arg_shortlist -gt 0 ]]; then
|
if [[ $arg_shortlist -gt 0 ]]; then
|
||||||
out="phlog topic recipe edit-config create-config update-git -v -h -d"
|
out="phlog topic recipe edit-config create-config update-burrow update-git -v -h -d"
|
||||||
# include long options only if using gnu getopt
|
# include long options only if using gnu getopt
|
||||||
getopt -T > /dev/null
|
getopt -T > /dev/null
|
||||||
if [ $? -eq 4 ]; then
|
if [ $? -eq 4 ]; then
|
||||||
|
@ -436,6 +471,10 @@ function main {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ ${arg_update_burrow} -gt 0 ]]; then
|
||||||
|
update_burrow
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ ${arg_update_git} -gt 0 ]]; then
|
if [[ ${arg_update_git} -gt 0 ]]; then
|
||||||
update_git
|
update_git
|
||||||
fi
|
fi
|
||||||
|
|
12
burrow.1
12
burrow.1
|
@ -1,4 +1,4 @@
|
||||||
.TH BURROW 1 "06 Mar 2018" "version 1.2.5"
|
.TH BURROW 1 "06 Mar 2018" "version 1.2.6"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
burrow \- a helper for building and managing a gopher hole
|
burrow \- a helper for building and managing a gopher hole
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
@ -30,6 +30,16 @@ If the gopher directory resides within a git repository, this action will do a
|
||||||
silent
|
silent
|
||||||
.B git-pull
|
.B git-pull
|
||||||
which is useful for crons.
|
which is useful for crons.
|
||||||
|
.TP
|
||||||
|
.B update-burrow
|
||||||
|
Burrow will attempt to auto-update. If the local folder where burrow is
|
||||||
|
installed is a git repository, burrow will pull the latest commit from the
|
||||||
|
remote branch. If the local directory is not a git remote, burrow will attempt
|
||||||
|
to update local files with their counterpart on the Github remote repository.
|
||||||
|
The local directory will only attempt to update files in this way which are
|
||||||
|
named
|
||||||
|
.I burrow
|
||||||
|
or some variation of that name.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
.B -v, --version
|
.B -v, --version
|
||||||
|
|
Loading…
Reference in New Issue