Browse Source

new: [myc-update] allow to update with an other branch than master

rc1
Valentin Lab 2 years ago
parent
commit
a2478abadf
  1. 13
      bin/myc-update

13
bin/myc-update

@ -10,19 +10,26 @@ include pretty
start=$SECONDS start=$SECONDS
if [ -z "$NO_UPDATE" -a -d "/opt/apps/myc-manage" ]; then if [ -z "$NO_UPDATE" -a -d "/opt/apps/myc-manage" ]; then
MYC_UPDATE_VERSION="${MYC_UPDATE_VERSION:-master}"
Elt "Checking if myc-manage requires update..." Elt "Checking if myc-manage requires update..."
cd /opt/apps/myc-manage cd /opt/apps/myc-manage
REMOTE_HEAD="$(git ls-remote origin refs/heads/master 2>/dev/null | cut -f 1)"
REMOTE_HEAD="$(git ls-remote origin "refs/heads/${MYC_UPDATE_VERSION}" 2>/dev/null | cut -f 1)"
if [ -z "$REMOTE_HEAD" ]; then
err "Can't find remote branch '$MYC_UPDATE_VERSION'."
echo " - Either this branch is not available on 'origin' remote." >&2
echo " - Either 'origin' remote is not correctly set." >&2
exit 1
fi
HEAD="$(git rev-parse HEAD)" HEAD="$(git rev-parse HEAD)"
if [ "$REMOTE_HEAD" != "$HEAD" ]; then if [ "$REMOTE_HEAD" != "$HEAD" ]; then
print_info "new version available" print_info "new version available"
Wrap -d "Update myc-manage" <<EOF || exit 1 Wrap -d "Update myc-manage" <<EOF || exit 1
if ! [ -d "/opt/apps/myc-manage" ]; then if ! [ -d "/opt/apps/myc-manage" ]; then
mkdir -p /opt/apps && cd /opt/apps mkdir -p /opt/apps && cd /opt/apps
git clone https://git.myceliandre.fr/Myceliandre/myc-manage.git
git clone https://git.myceliandre.fr/Myceliandre/myc-manage.git -b "$MYC_UPDATE_VERSION"
else else
cd /opt/apps/myc-manage && cd /opt/apps/myc-manage &&
git checkout master &&
git checkout "$MYC_UPDATE_VERSION" &&
git pull -r || exit 1 git pull -r || exit 1
fi fi

Loading…
Cancel
Save