git-garbage 1.1.4 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/garbage.sh +23 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,4 +26,8 @@ npm install --global git-garbage
|
|
|
26
26
|
|
|
27
27
|
## License
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
**miconfig** © [Kiko Beats](https://kikobeats.com), released under the [MIT](https://github.com/Kikobeats/git-garbage/blob/master/LICENSE.md) License. Logo by [Absurd Design](https://absurd.design).<br>
|
|
30
|
+
|
|
31
|
+
Authored and maintained by [Kiko Beats](https://kikobeats.com) with help from [contributors](https://github.com/Kikobeats/miconfig/contributors).
|
|
32
|
+
|
|
33
|
+
> [kikobeats.com](https://kikobeats.com) · GitHub [Kiko Beats](https://github.com/Kikobeats) · Twitter [@Kikobeats](https://twitter.com/Kikobeats)
|
package/garbage.sh
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/bin/bash
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
2
|
|
|
3
3
|
if test -n "$(git status --porcelain)"; then
|
|
4
4
|
echo 'Unclean working tree. Commit or stash changes first.' >&2;
|
|
@@ -10,23 +10,36 @@ if ! git fetch --quiet 2> /dev/null; then
|
|
|
10
10
|
exit 1;
|
|
11
11
|
fi
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
current="$(git rev-parse --abbrev-ref HEAD)"
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
git for-each-ref --format "${1:-}%(refname:short)" refs/heads/ --merged | egrep -v "$CURRENT_BRANCH"
|
|
17
|
-
}
|
|
15
|
+
declare -a branches
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
# merged
|
|
18
|
+
for branch in $(git for-each-ref --format "%(refname:short)" refs/heads/ --merged | grep -E -v "$current"); do
|
|
19
|
+
branches+=("$branch")
|
|
20
|
+
done
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
# squashed
|
|
23
|
+
for branch in $(git for-each-ref --format "%(refname:short)" refs/heads/); do
|
|
24
|
+
mergeBase=$(git merge-base "$current" "$branch")
|
|
25
|
+
if [[ $(git cherry "$current" "$(git commit-tree "$(git rev-parse "$branch^{tree}")" -p "$mergeBase" -m _)") == "-"* ]]; then
|
|
26
|
+
branches+=("$branch")
|
|
27
|
+
fi
|
|
28
|
+
done
|
|
29
|
+
|
|
30
|
+
if [[ ${#branches[@]} -eq 0 ]]; then
|
|
22
31
|
printf "\n Nothing to garbage."
|
|
23
32
|
exit
|
|
24
33
|
fi
|
|
25
34
|
|
|
26
|
-
echo
|
|
35
|
+
echo
|
|
36
|
+
printf ' %s\n' "${branches[@]}"
|
|
37
|
+
echo
|
|
38
|
+
|
|
27
39
|
read -rp " Will be removed. Continue? (y/N) " -n 1
|
|
28
40
|
|
|
29
41
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
30
|
-
|
|
31
|
-
|
|
42
|
+
echo && echo
|
|
43
|
+
message=$(git branch -D "${branches[@]}")
|
|
44
|
+
echo "${message//Deleted/ Deleted}"
|
|
32
45
|
fi
|
package/package.json
CHANGED