-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrebase-all
More file actions
executable file
·82 lines (71 loc) · 2.34 KB
/
rebase-all
File metadata and controls
executable file
·82 lines (71 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env bash
[[ -f .fork-config ]] || {
echo
echo "ERROR: No .fork-config found." >&2
echo >&2
echo "Copy .fork-config.example to .fork-config and update your details there." >&2
exit 1
}
source ./.fork-config
source ./functions.sh
fetchRemotes() {
# echo hi42
# local REPO=$1
# local DIR=$2
# local LABEL=$3
# local TEMP=$4
{
echo "remotes: $(git remote | tr "\n" " ")"
git fetch --all -q
} | labeledOutput $LABEL "fetch | "
}
# eachRepo "fetching upstream changes" fetchRemotes
eachRepo parallel buffered "Fetching upstream changes" fetchRemotes
wait
rebaseRepo() {
{
# commits we have pending, not merged to origin/main:
# git log --pretty="%h %as %<(8,trunc)%aN %s%Cblue% d" origin/main..HEAD
# commits we need to replay on top of:
REBASE_NEEDED=$(
git -c color.ui=always log --pretty="%h %as %<(18,trunc)%aN %<(80,trunc)%s " HEAD..origin/main
)
[[ $REBASE_NEEDED ]] && {
echo "needs rebase to include commits: "
echo "$REBASE_NEEDED"
STASHED=""
# check silently if there are pending changes needing to be stashed:
git diff --quiet || {
echo "Uncommitted changes. Stashing..."
git stash save
STASHED=1
}
git diff-index --quiet HEAD || {
echo "Uncommitted changes in index. Stashing..."
git stash save
STASHED=1
}
git rebase origin/main 2>&1
[[ $STASHED ]] && {
echo "Popping stash..."
git stash pop
}
git -c color.ui=always status | grep -v "nothing to commit"
git -c color.ui=always status --show-stash | grep -v "nothing to commit"
}
# list commits that are in origin/main but not in HEAD
# echo "Commits in origin/main but not in HEAD:"
# git log --pretty="%h %as %<(8,trunc)%aN %s%Cblue% d" origin/main..HEAD
} | labeledOutput $LABEL
}
rebaseActivity=$(
eachRepo parallel buffered "rebasing" rebaseRepo
)
[[ -z $rebaseActivity ]] && {
echo "No rebases needed."
echo
echo "Next: check repo status with ./gsall or Ctrl-C to exit"
echo
read -p "Next: $ " -e -i"./gsall" COMMAND_IGNORED
./gsall
}