Public Access
CertZipDL
This commit is contained in:
+22
-7
@@ -11,6 +11,15 @@ command -v git >/dev/null || fail "Git is not installed."
|
||||
|
||||
git config --global core.autocrlf input >/dev/null 2>&1 || true
|
||||
|
||||
if [ -z "$(git config user.email || git config --global user.email)" ]; then
|
||||
cat >&2 <<'MSG'
|
||||
Git does not know who you are. Set that once:
|
||||
git config --global user.email "you@example.com"
|
||||
git config --global user.name "Your Name"
|
||||
MSG
|
||||
exit 1
|
||||
fi
|
||||
|
||||
[ -d .git ] || git init -b main || fail "git init failed."
|
||||
|
||||
if git remote | grep -qx origin; then
|
||||
@@ -19,6 +28,11 @@ else
|
||||
git remote add origin "$REMOTE"
|
||||
fi
|
||||
|
||||
# Whatever branch is checked out, not a hard-coded one.
|
||||
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
[ -n "$BRANCH" ] && [ "$BRANCH" != "HEAD" ] || fail "No branch is checked out here."
|
||||
echo "Branch: $BRANCH"
|
||||
|
||||
# An unfinished rebase or merge blocks everything below, and git's own error is
|
||||
# easy to mistake for a push problem.
|
||||
GIT_DIR_PATH=$(git rev-parse --git-dir 2>/dev/null || echo .git)
|
||||
@@ -51,28 +65,29 @@ fi
|
||||
|
||||
git fetch origin || fail "Could not reach Gitea."
|
||||
|
||||
if git ls-remote --heads origin main | grep -q main; then
|
||||
BEHIND=$(git rev-list --count HEAD..origin/main 2>/dev/null || echo 0)
|
||||
if git ls-remote --heads origin "$BRANCH" | grep -q "$BRANCH"; then
|
||||
BEHIND=$(git rev-list --count "HEAD..origin/$BRANCH" 2>/dev/null || echo 0)
|
||||
if [ "$BEHIND" -gt 0 ]; then
|
||||
echo "The server has $BEHIND commit(s) this folder does not. Replaying your work on top..."
|
||||
if ! git pull --rebase origin main; then
|
||||
if ! git pull --rebase origin "$BRANCH"; then
|
||||
cat >&2 <<'MSG'
|
||||
|
||||
The two histories could not be joined automatically.
|
||||
|
||||
See what is on the server that you do not have:
|
||||
git log --oneline HEAD..origin/main
|
||||
git log --oneline HEAD..origin/$BRANCH
|
||||
|
||||
If that is nothing you need, and this folder is the good copy:
|
||||
git push --force-with-lease origin main
|
||||
git push --force-with-lease origin $BRANCH
|
||||
MSG
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
git push -u origin main || fail "The push was rejected. Read the message above. Nothing was sent."
|
||||
git push -u origin "$BRANCH" || fail "The push was rejected. Read the message above. Nothing was sent."
|
||||
|
||||
echo
|
||||
echo "Pushed successfully."
|
||||
echo "Pushed $BRANCH successfully."
|
||||
git log --oneline -1
|
||||
echo "https://gitea.hideawaygaming.com.au/jessikitty/visitor-signin"
|
||||
|
||||
Reference in New Issue
Block a user