Add branch function

Fix indentation
Fix typo
This commit is contained in:
Yogesh Sharma 2024-11-20 11:57:39 -05:00
parent b2627558b7
commit f08a8ed24e
Signed by: yogesh.sharma
GPG key ID: 47778BF1D2A81254

59
pg-env
View file

@ -36,11 +36,11 @@ commitfest() {
echo "Run this command from PostgreSQL git checkout" echo "Run this command from PostgreSQL git checkout"
fi fi
if [ $# -eq 2 ]; then if [ $# -eq 2 ]; then
IsBranchPreset=$( git worktree list | grep '\[CF_${FestID}_${EntryID}\]' ) IsBranchPresent=$( git worktree list | grep '\[CF_${FestID}_${EntryID}\]' )
else else
IsBranchPreset=$( git worktree list | grep '\[${3}_CF_${FestID}_${EntryID}\]' ) IsBranchPresent=$( git worktree list | grep '\[CF_${FestID}_${EntryID}_${3}\]' )
fi fi
if [ ! -z "${IsBranchPreset}" ]; then if [ ! -z "${IsBranchPresent}" ]; then
EXIT_VALUE=1 EXIT_VALUE=1
echo "Worktree already present, to remove it use following" echo "Worktree already present, to remove it use following"
echo "git worktree remove --force <worktree dir>" echo "git worktree remove --force <worktree dir>"
@ -59,10 +59,52 @@ commitfest() {
exit $EXIT_VALUE exit $EXIT_VALUE
} }
branch() {
shift
branch_name=$1
echo "Create new worktree for ${branch_name}"
EXIT_VALUE=0
if [ $# -ne 1 ] && [ $# -ne 2 ]; then
EXIT_VALUE=1
echo "Usage: $0 branch <Name of new Branch>"
echo "or"
echo "Usage: $0 branch <Name of new Branch <PG_RELEASED_BRANCH_NAME>"
fi
if [ ! -f src/include/postgres.h ] || [ ! -d .git ] ; then
EXIT_VALUE=1
echo "Run this command from PostgreSQL git checkout"
fi
if [ $# -eq 2 ]; then
IsBranchPresent=$( git worktree list | grep '\[${branch_name}\]' )
else
IsBranchPresent=$( git worktree list | grep '\[${branch_name}_${2}\]' )
fi
if [ ! -z "${IsBranchPresent}" ]; then
EXIT_VALUE=1
echo "Worktree already present, to remove it use following"
echo "git worktree remove --force <worktree dir>"
echo "git branch -d <branch name>"
fi
if [ $EXIT_VALUE -eq 0 ]; then
if [ $# -eq 1 ]; then
git worktree add --track -b ${branch_name} ../postgresql-${branch_name}
create_pgenv HEAD postgresql-${branch_name}
else
git worktree add --track -b ${branch_name}_${2} ../postgresql-${branch_name}_${2} origin/$2
create_pgenv $(grep PACKAGE_VERSION ../postgresql-${branch_name}_${2}/configure | grep -o '[0-9]*' | head -1) postgresql-${branch_name}_${2}
fi
EXIT_VALUE=$?
fi
exit $EXIT_VALUE
}
if [ "$0" = "$BASH_SOURCE" ]; then if [ "$0" = "$BASH_SOURCE" ]; then
if [ "$1" = "commitfest" ]; then if [ "$1" = "commitfest" ]; then
commitfest $@ commitfest $@
fi fi
if [ "$1" = "branch" ]; then
branch $@
fi
echo "source $0" echo "source $0"
exit 1 exit 1
fi fi
@ -152,9 +194,9 @@ distclean() {
compile() { compile() {
pushd ${PG_DEV_SRC} pushd ${PG_DEV_SRC}
if [ -z ${MESON_BUILD_PRESENT} ]; then if [ -z ${MESON_BUILD_PRESENT} ]; then
time ./configure --prefix=${PG_DEV_INST} --enable-debug --with-pgport=${PGPORT} --with-lz4 --with-ssl=openssl --with-python --with-perl --enable-debug --enable-cassert --enable-tap-tests CFLAGS="-ggdb -O0 -g3 -ggdb3 -fno-omit-frame-pointer ${PG_ENV_CFLAGS}" | tee /tmp/pg_compile.log (time ./configure --prefix=${PG_DEV_INST} --enable-injection-points --enable-debug --with-pgport=${PGPORT} --with-lz4 --with-ssl=openssl --with-python --with-perl --enable-debug --enable-cassert --enable-tap-tests CFLAGS="-ggdb -O0 -g3 -ggdb3 -fno-omit-frame-pointer ${PG_ENV_CFLAGS}") |& tee /tmp/pg_compile.log
else else
time meson setup build --prefix=${PG_DEV_INST} -Dpgport=${PGPORT} -Dlz4=enabled -Dssl=openssl -Dplpython=enabled -Dplperl=enabled -Ddebug=true -Dcassert=true -Dtap_tests=enabled -Dc_args="-ggdb -O0 -g3 -ggdb3 -fno-omit-frame-pointer ${PG_ENV_CFLAGS}" | tee /tmp/pg_compile.log (time meson setup build --prefix=${PG_DEV_INST} -Dpgport=${PGPORT} -Dlz4=enabled -Dssl=openssl -Dplpython=enabled -Dplperl=enabled -Ddebug=true -Dcassert=true -Dtap_tests=enabled -Dc_args="-ggdb -O0 -g3 -ggdb3 -fno-omit-frame-pointer ${PG_ENV_CFLAGS}") |& tee /tmp/pg_compile.log
fi fi
if [ $? -gt 0 ]; then if [ $? -gt 0 ]; then
if [ -z ${MESON_BUILD_PRESENT} ]; then if [ -z ${MESON_BUILD_PRESENT} ]; then
@ -164,9 +206,9 @@ compile() {
fi fi
else else
if [ -z ${MESON_BUILD_PRESENT} ]; then if [ -z ${MESON_BUILD_PRESENT} ]; then
make install | tee -a /tmp/pg_compile.log (time make install) |& tee -a /tmp/pg_compile.log
else else
(cd build; ninja -v install) | tee -a /tmp/pg_compile.log (cd build; time ninja -v install) |& tee -a /tmp/pg_compile.log
fi fi
if [ $? -gt 0 ]; then if [ $? -gt 0 ]; then
echo "make install failed" echo "make install failed"
@ -178,7 +220,7 @@ compile() {
compile_contrib() { compile_contrib() {
if [ -z ${MESON_BUILD_PRESENT} ]; then if [ -z ${MESON_BUILD_PRESENT} ]; then
pushd ${PG_DEV_SRC}/contrib pushd ${PG_DEV_SRC}/contrib
time make install | tee -a /tmp/pg_compile.log (time make install) |& tee -a /tmp/pg_compile.log
if [ $? -gt 0 ]; then if [ $? -gt 0 ]; then
echo "make install failed" echo "make install failed"
fi fi
@ -214,6 +256,7 @@ restartdb(){
} }
cleandb(){ cleandb(){
stopdb "$@"
if [ -z "$1" ]; then if [ -z "$1" ]; then
[ -n "$ZSH_VERSION" ] && setopt localoptions rmstarsilent [ -n "$ZSH_VERSION" ] && setopt localoptions rmstarsilent
rm -rf $PGDATA/* rm -rf $PGDATA/*