From d74cd1d48970bffcc8434ba78ac340a7490a79fb Mon Sep 17 00:00:00 2001 From: kalle Date: Sat, 23 Aug 2025 19:59:23 +0200 Subject: [PATCH] 2025-08-23T19:59:23+02:00 --- pull.sh | 18 ++++++++++++++++++ push.sh | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100755 pull.sh create mode 100755 push.sh diff --git a/pull.sh b/pull.sh new file mode 100755 index 0000000..e5745d7 --- /dev/null +++ b/pull.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +# Define the branch name +BRANCH_NAME="dev" + +if [ ! $(git rev-parse --abbrev-ref HEAD) == $BRANCH_NAME ]; then + + # Fetch the latest changes from the remote + git fetch origin + + # If the branch exists, just switch to it + git switch $BRANCH_NAME || (git switch -c $BRANCH_NAME && git push -u origin $BRANCH_NAME) + +fi + +# get the latest changes +git pull origin $BRANCH_NAME --ff-only + diff --git a/push.sh b/push.sh new file mode 100755 index 0000000..17f85e6 --- /dev/null +++ b/push.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +# Define the branch name +BRANCH_NAME=dev + +# Check if the branch exists locally +if git rev-parse --verify $BRANCH_NAME > /dev/null 2>&1; then + + # Get commit message + # message=$(git diff | ~/scripts/shelly 'write a short git commit message for this diff') + message="$(date --iso-8601=seconds)" + echo $message + + # Add and commit changes + git add . + git commit -m "$message" + + # Pull the latest changes from the main branch to ensure we're up to date + git pull origin main + + # Push the changes to the remote branch named dev_$(hostname) + git push origin $BRANCH_NAME + + # Merge to main + git switch main + git merge dev + git commit + git push + + # Switch to the branch + git switch $BRANCH_NAME + +else + echo "Branch $BRANCH_NAME does not exist locally!" + exit 1 +fi