From 0fdea7a17a9eac5d5edaf21307f2e28280427fe7c6b9f6fbbcaee2ef140474ac Mon Sep 17 00:00:00 2001 From: Minimons Date: Fri, 3 Jul 2026 11:58:18 +0200 Subject: [PATCH] X: Update publishGitHub script --- publishGitHub.sh | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/publishGitHub.sh b/publishGitHub.sh index 22c7411..fdf9488 100755 --- a/publishGitHub.sh +++ b/publishGitHub.sh @@ -1,8 +1,27 @@ #!/usr/bin/env bash set -euo pipefail -SOURCE="$HOME/projects/com_r35157_nenjim-hubd-impl_ref" -TARGET="$HOME/projects/com_r35157_nenjim-hubd-impl_ref_github_snapshot" +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " >&2 + exit 1 +fi + +BRANCH="$1" + +SOURCE="$HOME/projects/com_r35157_nenjim-hubd-api" +TARGET="$HOME/projects/com_r35157_nenjim-hubd-api_github_snapshot" + +cd "$TARGET" + +git fetch origin + +if git show-ref --verify --quiet "refs/heads/$BRANCH"; then + git switch "$BRANCH" +elif git show-ref --verify --quiet "refs/remotes/origin/$BRANCH"; then + git switch --track "origin/$BRANCH" +else + git switch --create "$BRANCH" +fi rsync -a --delete \ --exclude '.git' \ @@ -11,13 +30,12 @@ rsync -a --delete \ "$SOURCE/" \ "$TARGET/" -cd "$TARGET" git add -A if git diff --cached --quiet; then - echo "No snapshot changes to publish." + echo "No snapshot changes to publish on branch '$BRANCH'." exit 0 fi git commit -m "Mirror snapshot" -git push +git push -u origin "$BRANCH" \ No newline at end of file