Skip to content

Commit

Permalink
Added scripts to update application
Browse files Browse the repository at this point in the history
  • Loading branch information
toniginard committed May 23, 2024
1 parent b357439 commit c67f6ff
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 0 deletions.
26 changes: 26 additions & 0 deletions prepare_release_for_github.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

if [ "$#" -ne 1 ] ; then
echo "Script to compress the release"
echo "Usage: prepare_release.sh <version>"
echo "Usage example: ./prepare_release_for_github.sh 14.09.30"
exit 0
fi

version=$1
app=odissea
filename=$app"_v"$version

cd /tmp
git clone https://github.com/projectestac/$app.git
cd $app
git submodule update --recursive --init

find . -name '\.git*' -exec rm -rf {} \;

echo "Creating file $filename.tar.gz"
tar cfzp ../$filename.tar.gz *

echo "Creating file $filename.zip"
zip -r -q ../$filename.zip .
echo "Done"
15 changes: 15 additions & 0 deletions update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

source "update_functions.sh"

get_action $1

echo 'Pull inicial'
git_pull master

pull_submodules

echo "Garbage collecting..."
git gc

echo "That's all folks!"
30 changes: 30 additions & 0 deletions update_app_from_parent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# Call example: ./update_app_from_parent.sh

version=20.11.03

pushd /tmp

git clone https://github.com/projectestac/agora_moodle2.git
git clone https://github.com/projectestac/odissea.git

pushd agora_moodle2
git submodule update --init --recursive
find . -name '\.git*' -exec rm -rf {} \; 2>/dev/null
popd

data=`date +"%Y%m%d"`

pushd odissea
git checkout -b UPSTREAM origin/UPSTREAM
rm -rf html/
mv ../agora_moodle2 html
git add -A
git commit -m 'Updated from agora_moodle2 repository ('$data')'
git push origin UPSTREAM
popd

popd

printf "\nRemaining work: rebase master using UPSTREAM. Conflicts may arise.\n"
109 changes: 109 additions & 0 deletions update_functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#!/bin/bash

function gitcheckout {
dir=$1
branch=$2
remote=$3

if [ ! "$(ls -A $dir)" ]; then
# Empty directory
update_exec "git submodule sync --recursive"
update_exec "git submodule update --init --recursive"

if [ ! "$(ls -A $dir)" ]; then
echo 'ERROR: el directori $dir no existeix o és buit'
exit -1
fi
fi

echo "Entrant $dir BRANCH $branch REPO $remote ..."
pushd $dir > /dev/null
if [ ! -z "$remote" ]; then
update_exec "git remote set-url origin $remote"
update_exec "git fetch"
fi

update_exec "git checkout $branch"

git_pull $branch

popd > /dev/null
echo 'OK'
}

function git_pull {
branch=$1
if [[ $action == 'stash' ]]
then
update_exec "git stash"
fi

if [[ $action == 'reset' ]]
then
update_exec "git reset --hard origin/$branch"
fi

update_exec "git pull"

if [[ $action == 'stash' ]]
then
if [[ -n $(git stash list) ]]; then
echo ' >>>> Aplicat Stash'
update_exec "git stash pop"
fi
fi

if [[ $action == 'gc' ]]
then
update_exec "git gc"
fi
}

function update_exec {
if ! $1 > /dev/null
then
echo >&2 "ERROR: on $1"

exit 0
fi
}

function get_action {
tempaction=$1

if [[ $tempaction == 'reset' ]]
then
echo 'Demanat RESET'
action=$tempaction
elif [[ $tempaction == 'stash' ]]
then
echo 'Demanat STASH'
action=$tempaction
elif [[ $tempaction == 'gc' ]]
then
echo 'Demanat GC'
action=$tempaction
else
action=""
fi
}

function pull_submodules {
if [[ $action != 'reset' ]]
then
echo 'Inicialitzant submòduls...'
update_exec "git submodule update --recursive --init"

echo 'Sincronitzant submòduls...'
update_exec "git submodule sync"
fi

./update_submodules.sh
}

function end_exec {
echo "Garbage collecting..."
git gc

echo "That's all folks!"
}
7 changes: 7 additions & 0 deletions update_submodules.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

source "update_functions.sh"

gitcheckout "html/admin/tool/odisseagtafsync" "master" "[email protected]:projectestac/moodle-admin_odisseagtafsync.git"
gitcheckout "html/blocks/configurable_reports" "MOODLE_36_STABLE" "https://github.com/jleyva/moodle-block_configurablereports.git"
gitcheckout "html/auth/saml2" "master" "https://github.com/projectestac/moodle-auth_saml2.git"

0 comments on commit c67f6ff

Please sign in to comment.