add git build init command
This commit is contained in:
30
git-build-init.sh
Executable file
30
git-build-init.sh
Executable file
@@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
read -p "Set build branch prefix [build]:" BUILD_BRANCH_PREFIX
|
||||||
|
BUILD_BRANCH_PREFIX="${BUILD_BRANCH_PREFIX:=build}"
|
||||||
|
git config --local build.branch.prefix $BUILD_BRANCH_PREFIX
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
|
||||||
|
read -p "Set build commit messages [build from \$(date --utc)]:" BUILD_COMMIT_MSG
|
||||||
|
BUILD_COMMIT_MSG=${BUILD_COMMIT_MSG:='build from $(date --utc)'}
|
||||||
|
git config --local build.commit.messages "$BUILD_COMMIT_MSG"
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
|
||||||
|
read -p "Add remote build repo[false]:" BUILD_REMOTE_ENABLE
|
||||||
|
BUILD_REMOTE_ENABLE="${BUILD_REMOTE_ENABLE:=false}"
|
||||||
|
git config --local build.remote.enable $BUILD_REMOTE_ENABLE
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
|
||||||
|
if [ "$BUILD_REMOTE_ENABLE" == "true" ]; then
|
||||||
|
read -p "Set build remote name [build]:" BUILD_REMOTE_NAME
|
||||||
|
BUILD_REMOTE_NAME="${BUILD_REMOTE_NAME:=build}"
|
||||||
|
git config --local build.remote.name $BUILD_REMOTE_NAME
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
|
||||||
|
read -p "Set build remote url:" BUILD_REMOTE_URL
|
||||||
|
git remote add "$BUILD_REMOTE_NAME" "$BUILD_REMOTE_URL"
|
||||||
|
fi
|
||||||
12
git-build.sh
12
git-build.sh
@@ -1,4 +1,10 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
COMMAND=$1
|
||||||
|
if [ "$COMMAND" == "init" ]; then
|
||||||
|
./git-build-init.sh
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
ORIGIN_BRANCH_NAME=$(git symbolic-ref HEAD | sed 's!refs\/heads\/!!'| sed 's!build\/!!')
|
ORIGIN_BRANCH_NAME=$(git symbolic-ref HEAD | sed 's!refs\/heads\/!!'| sed 's!build\/!!')
|
||||||
BUILD_COMMIT_MSG=$(git config --default "build from $(date --utc)" --get build.commit.messages)
|
BUILD_COMMIT_MSG=$(git config --default "build from $(date --utc)" --get build.commit.messages)
|
||||||
BUILD_BRANCH_PREFIX=$(git config --default "build" --get build.branch.prefix)
|
BUILD_BRANCH_PREFIX=$(git config --default "build" --get build.branch.prefix)
|
||||||
@@ -8,8 +14,8 @@ BUILD_BRANCH_NAME="$BUILD_BRANCH_PREFIX/$ORIGIN_BRANCH_NAME"
|
|||||||
|
|
||||||
git checkout -B $BUILD_BRANCH_NAME
|
git checkout -B $BUILD_BRANCH_NAME
|
||||||
git add --all
|
git add --all
|
||||||
git commit -m "$BUILD_COMMIT_MSG"
|
git commit -m "$(eval echo $BUILD_COMMIT_MSG)"
|
||||||
|
|
||||||
if [ "$BUILD_REMOTE_ENABLE" == "true" ]; then
|
if [ "$BUILD_REMOTE_ENABLE" == "true" ]; then
|
||||||
git push --set-upstream $BUILD_REMOTE_NAME $BUILD_BRANCH_NAME
|
git push $BUILD_REMOTE_NAME $BUILD_BRANCH_NAME
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user