Skip to content

Commit

Permalink
feat: add feature branching
Browse files Browse the repository at this point in the history
  • Loading branch information
kjetilhp committed Nov 15, 2024
1 parent 2362860 commit 63e0caf
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions feath.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/sh
set -e
POSITIONAL_ARGS=()

while [[ $# -gt 0 ]]; do
case $1 in
-e|--extension)
EXTENSION="$2"
shift # past argument
shift # past value
;;
-s|--searchpath)
SEARCHPATH="$2"
shift # past argument
shift # past value
;;
--delete)
DELETE=YES
shift # past argument
;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument
;;
esac
done

set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters

# echo "extension: $EXTENSION"
# echo "searchpath: $SEARCHPATH"
# echo "default: $DEFAULT"
# echo "positional args: $@"
# echo "positional args: $POSITIONAL_ARGS"

if [ "$DELETE" == "YES" ] && [ [ "$@" == "master" ] || [ "$@" == "develop" ] || [ "$@" == "main" ]]
then
echo "Deleting master/main and develop branches not alloed"
exit 1
fi

if [ -z "$@" ]
then
echo "eksempel på kall: feat.sh <feature branch> (e.g 1234-feat-my-feature)"
exit 1
else
BRANCH=$@
echo "branch: "$BRANCH
fi

if [ "$DELETE" == "YES" ]
then
echo "Deleting branch: "$BRANCH
git branch -d $BRANCH
git push origin --delete feature-$BRANCH
else
echo "Creating branch: "$BRANCH
git checkout main
git pull
git checkout -b feature-$1 main
git push -u origin feature-$1
fi

0 comments on commit 63e0caf

Please sign in to comment.