git-garbage 1.1.9 → 1.1.11
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 +1 -1
- package/garbage.sh +33 -6
- package/package.json +12 -13
package/README.md
CHANGED
|
@@ -30,4 +30,4 @@ npm install --global git-garbage
|
|
|
30
30
|
|
|
31
31
|
Authored and maintained by [Kiko Beats](https://kikobeats.com) with help from [contributors](https://github.com/Kikobeats/miconfig/contributors).
|
|
32
32
|
|
|
33
|
-
> [kikobeats.com](https://kikobeats.com) · GitHub [Kiko Beats](https://github.com/Kikobeats) ·
|
|
33
|
+
> [kikobeats.com](https://kikobeats.com) · GitHub [Kiko Beats](https://github.com/Kikobeats) · X [@Kikobeats](https://x.com/Kikobeats)
|
package/garbage.sh
CHANGED
|
@@ -5,7 +5,7 @@ if test -n "$(git status --porcelain)"; then
|
|
|
5
5
|
exit 1;
|
|
6
6
|
fi
|
|
7
7
|
|
|
8
|
-
if ! git fetch --quiet 2> /dev/null; then
|
|
8
|
+
if ! git fetch --prune --quiet 2> /dev/null; then
|
|
9
9
|
echo 'There was a problem fetching your branch.' >&2;
|
|
10
10
|
exit 1;
|
|
11
11
|
fi
|
|
@@ -15,15 +15,42 @@ current="$(git rev-parse --abbrev-ref HEAD)"
|
|
|
15
15
|
declare -a branches
|
|
16
16
|
|
|
17
17
|
# merged
|
|
18
|
-
for branch in $(git for-each-ref --format "%(refname:short)" refs/heads/ --merged
|
|
19
|
-
|
|
18
|
+
for branch in $(git for-each-ref --format "%(refname:short)" refs/heads/ --merged); do
|
|
19
|
+
if [[ "$branch" != "$current" ]]; then
|
|
20
|
+
branches+=("$branch")
|
|
21
|
+
fi
|
|
20
22
|
done
|
|
21
23
|
|
|
22
24
|
# squashed
|
|
23
25
|
for branch in $(git for-each-ref --format "%(refname:short)" refs/heads/); do
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
if [[ "$branch" != "$current" ]]; then
|
|
27
|
+
mergeBase=$(git merge-base "$current" "$branch")
|
|
28
|
+
if [[ $(git cherry "$current" "$(git commit-tree "$(git rev-parse "$branch^{tree}")" -p "$mergeBase" -m _)") == "-"* ]]; then
|
|
29
|
+
branches+=("$branch")
|
|
30
|
+
fi
|
|
31
|
+
fi
|
|
32
|
+
done
|
|
33
|
+
|
|
34
|
+
# branches that were part of PR workflow (feature branches with remote deleted)
|
|
35
|
+
for branch in $(git for-each-ref --format "%(refname:short)" refs/heads/); do
|
|
36
|
+
if [[ "$branch" != "$current" ]]; then
|
|
37
|
+
# Check if branch has commits not in main (indicating it was a feature branch)
|
|
38
|
+
if [[ $(git rev-list --count "$current..$branch" 2>/dev/null) -gt 0 ]]; then
|
|
39
|
+
# Check if remote branch doesn't exist (indicating PR was closed and branch deleted)
|
|
40
|
+
if ! git show-ref --verify --quiet "refs/remotes/origin/$branch"; then
|
|
41
|
+
# Check if branch is already in our list to avoid duplicates
|
|
42
|
+
branch_exists=false
|
|
43
|
+
for existing_branch in "${branches[@]}"; do
|
|
44
|
+
if [[ "$existing_branch" == "$branch" ]]; then
|
|
45
|
+
branch_exists=true
|
|
46
|
+
break
|
|
47
|
+
fi
|
|
48
|
+
done
|
|
49
|
+
if [[ "$branch_exists" == false ]]; then
|
|
50
|
+
branches+=("$branch")
|
|
51
|
+
fi
|
|
52
|
+
fi
|
|
53
|
+
fi
|
|
27
54
|
fi
|
|
28
55
|
done
|
|
29
56
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "git-garbage",
|
|
3
3
|
"description": "Delete local git branches after deleting them on the remote repository.",
|
|
4
4
|
"homepage": "https://github.com/Kikobeats/git-garbage",
|
|
5
|
-
"version": "1.1.
|
|
5
|
+
"version": "1.1.11",
|
|
6
6
|
"bin": {
|
|
7
7
|
"git-garbage": "garbage.sh"
|
|
8
8
|
},
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"name": "Kiko Beats",
|
|
12
12
|
"url": "https://github.com/Kikobeats"
|
|
13
13
|
},
|
|
14
|
+
"contributors": [],
|
|
14
15
|
"repository": {
|
|
15
16
|
"type": "git",
|
|
16
17
|
"url": "git+https://github.com/kikobeats/git-garbage.git"
|
|
@@ -28,14 +29,12 @@
|
|
|
28
29
|
"@commitlint/config-conventional": "latest",
|
|
29
30
|
"@ksmithut/prettier-standard": "latest",
|
|
30
31
|
"ci-publish": "latest",
|
|
31
|
-
"conventional-github-releaser": "latest",
|
|
32
32
|
"finepack": "latest",
|
|
33
33
|
"git-authors-cli": "latest",
|
|
34
|
+
"github-generate-release": "latest",
|
|
34
35
|
"nano-staged": "latest",
|
|
35
|
-
"npm-check-updates": "latest",
|
|
36
36
|
"simple-git-hooks": "latest",
|
|
37
37
|
"standard": "latest",
|
|
38
|
-
"standard-markdown": "latest",
|
|
39
38
|
"standard-version": "latest"
|
|
40
39
|
},
|
|
41
40
|
"files": [
|
|
@@ -44,28 +43,28 @@
|
|
|
44
43
|
"scripts": {
|
|
45
44
|
"contributors": "(npx git-authors-cli && npx finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
|
|
46
45
|
"postrelease": "npm run release:tags && npm run release:github && (ci-publish || npm publish --access=public)",
|
|
47
|
-
"prerelease": "npm run
|
|
46
|
+
"prerelease": "npm run contributors",
|
|
48
47
|
"release": "standard-version -a",
|
|
49
|
-
"release:github": "
|
|
48
|
+
"release:github": "github-generate-release",
|
|
50
49
|
"release:tags": "git push --follow-tags origin HEAD:master",
|
|
51
|
-
"test": "exit 0"
|
|
52
|
-
"update": "ncu -u",
|
|
53
|
-
"update:check": "ncu -- --error-level 2"
|
|
50
|
+
"test": "exit 0"
|
|
54
51
|
},
|
|
55
52
|
"license": "MIT",
|
|
56
53
|
"commitlint": {
|
|
57
54
|
"extends": [
|
|
58
55
|
"@commitlint/config-conventional"
|
|
59
|
-
]
|
|
56
|
+
],
|
|
57
|
+
"rules": {
|
|
58
|
+
"body-max-line-length": [
|
|
59
|
+
0
|
|
60
|
+
]
|
|
61
|
+
}
|
|
60
62
|
},
|
|
61
63
|
"nano-staged": {
|
|
62
64
|
"*.js": [
|
|
63
65
|
"prettier-standard",
|
|
64
66
|
"standard --fix"
|
|
65
67
|
],
|
|
66
|
-
"*.md": [
|
|
67
|
-
"standard-markdown"
|
|
68
|
-
],
|
|
69
68
|
"package.json": [
|
|
70
69
|
"finepack"
|
|
71
70
|
]
|