Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F24367088
D3959.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
D3959.diff
View Options
diff --git a/roles/devserver/userland-home/files/dereckson/bin/arc-delete-remote-branch b/roles/devserver/userland-home/files/dereckson/bin/arc-delete-remote-branch
new file mode 100755
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/bin/arc-delete-remote-branch
@@ -0,0 +1,63 @@
+#!/bin/sh
+#
+# Usage: arc-delete-remote-branch [branch]
+# Default value: master
+#
+
+set -e
+
+# -------------------------------------------------------------
+# Parse arguments
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+if [ "$#" -gt 1 ]; then
+ branch=$1
+ shift
+else
+ branch=master
+fi
+
+# Assumes origin is the Arcanist clone
+remote=origin
+
+# -------------------------------------------------------------
+# Find repository code on Phabricator instance
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+REPO_PATH=$(git rev-parse --show-toplevel)
+REPO_RETCODE=$?
+
+if [ $REPO_RETCODE -ne 0 ]; then
+ exit $REPO_RETCODE
+fi;
+
+ARC_CONFIG=$REPO_PATH/.arcconfig
+
+if [ ! -f $ARC_CONFIG ]; then
+ echo "Can't find Arcanist configuration: $ARC_CONFIG" >&2
+ exit 2
+fi
+
+repo_callsign=$(cat $ARC_CONFIG | jq -r '.["repository.callsign"]')
+
+jq -n --arg callsign "$repo_callsign" '{
+ transactions: [
+ {
+ type: "allowDangerousChanges",
+ value: true
+ }
+ ],
+ objectIdentifier: ("r" + $callsign)
+}' | arc call-conduit -- diffusion.repository.edit
+
+git push $remote --delete $branch
+
+jq -n --arg callsign "$repo_callsign" '{
+ transactions: [
+ {
+ type: "allowDangerousChanges",
+ value: false
+ }
+ ],
+ objectIdentifier: ("r" + $callsign)
+}' | arc call-conduit -- diffusion.repository.edit
diff --git a/roles/devserver/userland-home/files/dereckson/bin/arc-merge-land b/roles/devserver/userland-home/files/dereckson/bin/arc-merge-land
new file mode 100755
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/bin/arc-merge-land
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+if [ $# -ne 1 ]
+then
+ >&2 echo "Usage: $(basename "$0") <branch name>"
+ exit 1
+fi
+
+REMOTE=origin
+EXCHANGE_REMOTE=datacube
+CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
+DEFAULT_BRANCH=$(git get-default-branch)
+LAND_BRANCH=$1
+
+git fetch --all
+
+# Scenario A. We're on that branch we can rebase, then use arc land
+if [ "$CURRENT_BRANCH" = "$LAND_BRANCH" ]; then
+ git rebase "$DEFAULT_BRANCH" && arc land --onto "$DEFAULT_BRANCH"
+ exit $?
+fi
+
+# Scenario B. Let's try to rebase and push
+set -e
+
+git checkout "$LAND_BRANCH"
+git rebase "$REMOTE/$DEFAULT_BRANCH"
+
+git checkout "$DEFAULT_BRANCH"
+git diff-index --quiet --cached HEAD -- && \
+git diff-files --quiet && git pull
+
+git merge --ff "$LAND_BRANCH"
+git branch -d "$LAND_BRANCH"
+arc amend
+git push "$REMOTE" "$DEFAULT_BRANCH"
+
+BRANCH_EXISTS=$(git ls-remote --heads "$EXCHANGE_REMOTE" "refs/heads/$LAND_BRANCH")
+test -n "$BRANCH_EXISTS" && git push "$EXCHANGE_REMOTE" --delete "$LAND_BRANCH"
diff --git a/roles/devserver/userland-home/files/dereckson/bin/arc-paste-file b/roles/devserver/userland-home/files/dereckson/bin/arc-paste-file
--- a/roles/devserver/userland-home/files/dereckson/bin/arc-paste-file
+++ b/roles/devserver/userland-home/files/dereckson/bin/arc-paste-file
@@ -13,4 +13,4 @@
exit 2
fi
-arc paste --title $FILE < $FILE
+arc paste --title $FILE -- < $FILE
diff --git a/roles/devserver/userland-home/files/dereckson/bin/arc-update-repo b/roles/devserver/userland-home/files/dereckson/bin/arc-update-repo
--- a/roles/devserver/userland-home/files/dereckson/bin/arc-update-repo
+++ b/roles/devserver/userland-home/files/dereckson/bin/arc-update-repo
@@ -19,4 +19,4 @@
exit
fi
-echo "{ \"callsigns\": [$CALLSIGN] }" | arc call-conduit diffusion.looksoon > /dev/null
+echo "{ \"callsigns\": [$CALLSIGN] }" | arc call-conduit diffusion.looksoon -- > /dev/null
diff --git a/roles/devserver/userland-home/files/dereckson/bin/git-bye b/roles/devserver/userland-home/files/dereckson/bin/git-bye
--- a/roles/devserver/userland-home/files/dereckson/bin/git-bye
+++ b/roles/devserver/userland-home/files/dereckson/bin/git-bye
@@ -1,14 +1,17 @@
#!/bin/sh
-BRANCH=$(git rev-parse --abbrev-ref HEAD)
+CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
+DEFAULT_BRANCH=$(git get-default-branch)
-if [ "$BRANCH" = "master" ]; then
- echo "You're already on the master branch."
+if [ "$CURRENT_BRANCH" = "$DEFAULT_BRANCH" ]; then
+ echo "You're already on the default branch '$DEFAULT_BRANCH'."
exit 1
fi
# Updates master branch if there isn't any staged change and working tree is clean
-git checkout master
-git diff-index --quiet --cached HEAD -- && git diff-files --quiet && git pull
+git checkout "$DEFAULT_BRANCH"
-git branch -D "$BRANCH"
+git diff-index --quiet --cached HEAD -- && \
+git diff-files --quiet && git pull
+
+git branch -D "$CURRENT_BRANCH"
diff --git a/roles/devserver/userland-home/files/dereckson/bin/git-clean-branches b/roles/devserver/userland-home/files/dereckson/bin/git-clean-branches
new file mode 100755
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/bin/git-clean-branches
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+set -eu
+
+arc branches | grep -v main | grep -v master | grep Closed
+arc --no-ansi branches | grep -v main | grep -v master | grep Closed | awk '{print $2}' | xargs git branch -D
diff --git a/roles/devserver/userland-home/files/dereckson/bin/git-delete-remote-branch b/roles/devserver/userland-home/files/dereckson/bin/git-delete-remote-branch
new file mode 100755
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/bin/git-delete-remote-branch
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# Usage: git delete-remote-branch [remote] [branch]
+# Default values: origin master
+#
+
+set -e
+
+if [ "$#" -gt 1 ]; then
+ remote=$1
+ shift
+else
+ remote=origin
+fi
+
+if [ "$#" -gt 0 ]; then
+ branch=$1
+ shift
+else
+ branch=master
+fi
+
+git push $remote --delete $branch
+
diff --git a/roles/devserver/userland-home/files/dereckson/bin/git-get-default-branch b/roles/devserver/userland-home/files/dereckson/bin/git-get-default-branch
new file mode 100755
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/bin/git-get-default-branch
@@ -0,0 +1,34 @@
+#!/bin/sh
+if [ $# -ne 0 ]
+then
+ >&2 echo "Usage: $(basename "$0")"
+ exit 1
+fi
+
+REPO_PATH=$(git rev-parse --show-toplevel)
+REPO_RETCODE=$?
+
+if [ $REPO_RETCODE -ne 0 ]
+then
+ exit $REPO_RETCODE
+fi;
+
+REPO=$(basename "$REPO_PATH")
+
+if [ "$REPO" = "puppet" ]
+then
+ DEFAULT_BRANCH=production
+elif [ "$REPO" = "pixelfed" ]
+then
+ DEFAULT_BRANCH=dev
+elif [ -f $REPO_PATH/.git/arc/default-relative-commit ]
+then
+ DEFAULT_BRANCH=$(awk -F / '{print $(NF)}' $REPO_PATH/.git/arc/default-relative-commit)
+elif git show-ref --verify --quiet refs/heads/main
+then
+ DEFAULT_BRANCH=main
+else
+ DEFAULT_BRANCH=master
+fi
+
+echo $DEFAULT_BRANCH
diff --git a/roles/devserver/userland-home/files/dereckson/bin/git-newbug b/roles/devserver/userland-home/files/dereckson/bin/git-newbug
--- a/roles/devserver/userland-home/files/dereckson/bin/git-newbug
+++ b/roles/devserver/userland-home/files/dereckson/bin/git-newbug
@@ -5,27 +5,10 @@
exit 1
fi
-BRANCH=$1
+WORKING_BRANCH=$1
+DEFAULT_BRANCH=$(git get-default-branch)
-REPO=$(git rev-parse --show-toplevel)
-REPO_RETCODE=$?
-
-if [ $REPO_RETCODE -ne 0 ]
-then
- exit $REPO_RETCODE
-fi;
-
-REPO=$(basename "$REPO")
-
-if [ "$REPO" = "puppet" ]
-then
- MASTER=production
-else
- MASTER=master
-fi
-
-git checkout $MASTER
+git switch "$DEFAULT_BRANCH"
git fetch --all
-git pull
-git pull origin $MASTER
-git checkout -b "$BRANCH"
+git pull origin "$DEFAULT_BRANCH"
+git switch -c "$WORKING_BRANCH"
diff --git a/roles/devserver/userland-home/files/dereckson/bin/git-recycle b/roles/devserver/userland-home/files/dereckson/bin/git-recycle
new file mode 100755
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/bin/git-recycle
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+# Recreates a pull request on GitHub / GitLab / Bitbucket
+# by cherry-pick the last commit. Allow to avoid to rebase
+# commits skipping all changes.
+
+CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
+DEFAULT_BRANCH=$(git get-default-branch)
+
+if [ "$CURRENT_BRANCH" = "$DEFAULT_BRANCH" ]; then
+ echo "You're on the master branch. This feature is intended for feature branches."
+ exit 1
+fi
+
+# Updates default branch if there isn't any staged change and working tree is clean
+git checkout "$DEFAULT_BRANCH"
+git diff-index --quiet --cached HEAD -- && git diff-files --quiet && git pull
+
+git branch -D "$CURRENT_BRANCH"
+git checkout -b "$CURRENT_BRANCH"
+
+# Recreate branch
+git cherry-pick "origin/$CURRENT_BRANCH"
+git push origin -f "$CURRENT_BRANCH"
diff --git a/roles/devserver/userland-home/files/dereckson/bin/git-regenerate-commit b/roles/devserver/userland-home/files/dereckson/bin/git-regenerate-commit
new file mode 100755
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/bin/git-regenerate-commit
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# Get needed information from HEAD commit
+message=$(git rev-list --format=%B --max-count=1 HEAD | tail +2)
+files=$(git diff-tree --no-commit-id --name-only HEAD -r)
+
+# Regenerate the commit
+git reset HEAD^
+git add $files
+echo $message | git commit -F -
diff --git a/roles/devserver/userland-home/files/dereckson/bin/git-respawn b/roles/devserver/userland-home/files/dereckson/bin/git-respawn
--- a/roles/devserver/userland-home/files/dereckson/bin/git-respawn
+++ b/roles/devserver/userland-home/files/dereckson/bin/git-respawn
@@ -1,19 +1,20 @@
#!/usr/bin/env bash
-BRANCH=$(git rev-parse --abbrev-ref HEAD)
+CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
+DEFAULT_BRANCH=$(git get-default-branch)
-if [ "$BRANCH" = "master" ]; then
- echo "You're already on the master branch."
- exit 1
+if [ "$CURRENT_BRANCH" = "$DEFAULT_BRANCH" ]; then
+ echo "You're on the default branch '$DEFAULT_BRANCH'. This feature is intended for feature branches."
+ exit 1
fi
-# Updates master branch if there isn't any staged change and working tree is clean
-git checkout master
+# Updates default branch if there isn't any staged change and working tree is clean
+git checkout "$DEFAULT_BRANCH"
git diff-index --quiet --cached HEAD -- && git diff-files --quiet && git pull
git branch -D "$BRANCH"
# Fetch new branch
-if [ ${BRANCH:0:10} = "arcpatch-D" ]; then
- arc patch ${BRANCH:9}
+if [ ${CURRENT_BRANCH:0:10} = "arcpatch-D" ]; then
+ arc patch ${CURRENT_BRANCH:9}
fi
diff --git a/roles/devserver/userland-home/files/dereckson/bin/git-update b/roles/devserver/userland-home/files/dereckson/bin/git-update
new file mode 100755
--- /dev/null
+++ b/roles/devserver/userland-home/files/dereckson/bin/git-update
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+BRANCH=$(git rev-parse --abbrev-ref HEAD)
+
+REPO=$(git rev-parse --show-toplevel)
+REPO_RETCODE=$?
+
+if [ $REPO_RETCODE -ne 0 ]
+then
+ exit $REPO_RETCODE
+fi;
+
+git fetch --all
+git reset origin/$BRANCH && git status
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Feb 17, 00:16 (16 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3454228
Default Alt Text
D3959.diff (10 KB)
Attached To
Mode
D3959: Sync Arcanist and Git helper scripts collection for Dereckson
Attached
Detach File
Event Timeline
Log In to Comment