@wipcomputer/post-merge-rename 1.0.0
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/LICENSE +52 -0
- package/SKILL.md +57 -0
- package/package.json +9 -0
- package/post-merge-rename.sh +122 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
Dual License: MIT + AGPLv3
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 WIP Computer, Inc.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
1. MIT License (local and personal use)
|
|
7
|
+
---------------------------------------
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
2. GNU Affero General Public License v3.0 (commercial and cloud use)
|
|
29
|
+
--------------------------------------------------------------------
|
|
30
|
+
|
|
31
|
+
If you run this software as part of a hosted service, cloud platform,
|
|
32
|
+
marketplace listing, or any network-accessible offering for commercial
|
|
33
|
+
purposes, the AGPLv3 terms apply. You must either:
|
|
34
|
+
|
|
35
|
+
a) Release your complete source code under AGPLv3, or
|
|
36
|
+
b) Obtain a commercial license.
|
|
37
|
+
|
|
38
|
+
This program is free software: you can redistribute it and/or modify
|
|
39
|
+
it under the terms of the GNU Affero General Public License as published
|
|
40
|
+
by the Free Software Foundation, either version 3 of the License, or
|
|
41
|
+
(at your option) any later version.
|
|
42
|
+
|
|
43
|
+
This program is distributed in the hope that it will be useful,
|
|
44
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
45
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
46
|
+
GNU Affero General Public License for more details.
|
|
47
|
+
|
|
48
|
+
You should have received a copy of the GNU Affero General Public License
|
|
49
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
AGPLv3 for personal use is free. Commercial licenses available.
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: post-merge-rename
|
|
3
|
+
description: Post-merge branch renaming. Appends --merged-YYYY-MM-DD to preserve history.
|
|
4
|
+
license: MIT
|
|
5
|
+
interface: [cli, skill]
|
|
6
|
+
metadata:
|
|
7
|
+
display-name: "Post-Merge Branch Naming"
|
|
8
|
+
version: "1.3.0"
|
|
9
|
+
homepage: "https://github.com/wipcomputer/wip-ai-devops-toolbox"
|
|
10
|
+
author: "Parker Todd Brooks"
|
|
11
|
+
category: dev-tools
|
|
12
|
+
capabilities:
|
|
13
|
+
- branch-rename
|
|
14
|
+
- history-preservation
|
|
15
|
+
requires:
|
|
16
|
+
bins: [git, bash]
|
|
17
|
+
openclaw:
|
|
18
|
+
requires:
|
|
19
|
+
bins: [git, bash]
|
|
20
|
+
emoji: "🏷️"
|
|
21
|
+
compatibility: Requires git, bash.
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
# post-merge-rename
|
|
25
|
+
|
|
26
|
+
Scans for merged branches that haven't been renamed and appends `--merged-YYYY-MM-DD` to preserve history. We never delete branches. We rename them.
|
|
27
|
+
|
|
28
|
+
## When to Use This Skill
|
|
29
|
+
|
|
30
|
+
**Use post-merge-rename for:**
|
|
31
|
+
- After merging PRs, to rename the source branch
|
|
32
|
+
- Cleaning up branches that were merged but not renamed
|
|
33
|
+
- Runs automatically as step 10 of `wip-release`
|
|
34
|
+
|
|
35
|
+
### Do NOT Use For
|
|
36
|
+
|
|
37
|
+
- Unmerged branches
|
|
38
|
+
- Branches you're currently working on
|
|
39
|
+
|
|
40
|
+
## API Reference
|
|
41
|
+
|
|
42
|
+
### CLI
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
bash scripts/post-merge-rename.sh # scan + rename all merged branches
|
|
46
|
+
bash scripts/post-merge-rename.sh --dry-run # preview only
|
|
47
|
+
bash scripts/post-merge-rename.sh <branch> # rename specific branch
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## What It Does
|
|
51
|
+
|
|
52
|
+
1. Lists all local branches merged into main
|
|
53
|
+
2. Skips branches already renamed (containing `--merged-`)
|
|
54
|
+
3. Finds the merge date from git history
|
|
55
|
+
4. Renames: `feature-branch` -> `feature-branch--merged-2026-03-09`
|
|
56
|
+
5. Pushes the renamed branch to origin
|
|
57
|
+
6. Deletes the old branch name from origin
|
package/package.json
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
#
|
|
3
|
+
# post-merge-rename.sh
|
|
4
|
+
# Scans for branches merged into main and renames them with --merged-YYYY-MM-DD.
|
|
5
|
+
# Branches already renamed (containing --merged-) are skipped.
|
|
6
|
+
# Never deletes branches. Only renames.
|
|
7
|
+
#
|
|
8
|
+
# Usage:
|
|
9
|
+
# bash post-merge-rename.sh # scan + rename all
|
|
10
|
+
# bash post-merge-rename.sh <branch> # rename a specific branch
|
|
11
|
+
# bash post-merge-rename.sh --dry-run # preview only
|
|
12
|
+
# bash post-merge-rename.sh <branch> --dry-run # preview specific branch
|
|
13
|
+
#
|
|
14
|
+
# Run this after merging a PR, or periodically to catch missed renames.
|
|
15
|
+
#
|
|
16
|
+
# Author: CC-mini (Opus 4.6)
|
|
17
|
+
# Date: 2026-03-08
|
|
18
|
+
|
|
19
|
+
set -euo pipefail
|
|
20
|
+
|
|
21
|
+
DRY_RUN=false
|
|
22
|
+
SPECIFIC_BRANCH=""
|
|
23
|
+
|
|
24
|
+
for arg in "$@"; do
|
|
25
|
+
case "$arg" in
|
|
26
|
+
--dry-run) DRY_RUN=true ;;
|
|
27
|
+
--help|-h)
|
|
28
|
+
echo "Usage: post-merge-rename.sh [<branch>] [--dry-run]"
|
|
29
|
+
echo ""
|
|
30
|
+
echo "Scans for branches merged into main and renames them"
|
|
31
|
+
echo "with --merged-YYYY-MM-DD suffix. Never deletes branches."
|
|
32
|
+
exit 0
|
|
33
|
+
;;
|
|
34
|
+
*) SPECIFIC_BRANCH="$arg" ;;
|
|
35
|
+
esac
|
|
36
|
+
done
|
|
37
|
+
|
|
38
|
+
# Must be in a git repo
|
|
39
|
+
if ! git rev-parse --is-inside-work-tree &>/dev/null; then
|
|
40
|
+
echo "Error: not inside a git repo."
|
|
41
|
+
exit 1
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
# Fetch latest remote state
|
|
45
|
+
git fetch origin --prune 2>/dev/null || true
|
|
46
|
+
|
|
47
|
+
rename_branch() {
|
|
48
|
+
local branch="$1"
|
|
49
|
+
local trimmed
|
|
50
|
+
trimmed=$(echo "$branch" | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$//')
|
|
51
|
+
|
|
52
|
+
# Skip main
|
|
53
|
+
[[ "$trimmed" == "main" || "$trimmed" == "master" ]] && return
|
|
54
|
+
|
|
55
|
+
# Skip already renamed
|
|
56
|
+
[[ "$trimmed" == *"--merged-"* ]] && return
|
|
57
|
+
|
|
58
|
+
# Skip current branch (can't rename the checked-out branch)
|
|
59
|
+
local current
|
|
60
|
+
current=$(git branch --show-current)
|
|
61
|
+
if [[ "$trimmed" == "$current" ]]; then
|
|
62
|
+
echo " SKIP $trimmed (currently checked out)"
|
|
63
|
+
return
|
|
64
|
+
fi
|
|
65
|
+
|
|
66
|
+
# Find merge date: when this branch's tip became reachable from main
|
|
67
|
+
local merge_date
|
|
68
|
+
merge_date=$(git log main --format="%ai" --ancestry-path "$(git merge-base main "$trimmed" 2>/dev/null)..main" 2>/dev/null | tail -1 | cut -d' ' -f1)
|
|
69
|
+
|
|
70
|
+
# Fallback: use the branch tip's own date
|
|
71
|
+
if [[ -z "$merge_date" ]]; then
|
|
72
|
+
merge_date=$(git log "$trimmed" -1 --format="%ai" 2>/dev/null | cut -d' ' -f1)
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
if [[ -z "$merge_date" ]]; then
|
|
76
|
+
echo " SKIP $trimmed (could not determine merge date)"
|
|
77
|
+
return
|
|
78
|
+
fi
|
|
79
|
+
|
|
80
|
+
local new_name="${trimmed}--merged-${merge_date}"
|
|
81
|
+
|
|
82
|
+
if $DRY_RUN; then
|
|
83
|
+
echo " [dry-run] $trimmed -> $new_name"
|
|
84
|
+
else
|
|
85
|
+
echo " Renaming: $trimmed -> $new_name"
|
|
86
|
+
|
|
87
|
+
# Rename local
|
|
88
|
+
git branch -m "$trimmed" "$new_name" 2>/dev/null || true
|
|
89
|
+
|
|
90
|
+
# Push new name to remote
|
|
91
|
+
git push origin "$new_name" 2>/dev/null || true
|
|
92
|
+
|
|
93
|
+
# Remove old name from remote
|
|
94
|
+
git push origin --delete "$trimmed" 2>/dev/null || true
|
|
95
|
+
fi
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if [[ -n "$SPECIFIC_BRANCH" && "$SPECIFIC_BRANCH" != "--dry-run" ]]; then
|
|
99
|
+
# Rename a specific branch
|
|
100
|
+
echo "Checking branch: $SPECIFIC_BRANCH"
|
|
101
|
+
if git merge-base --is-ancestor "$SPECIFIC_BRANCH" main 2>/dev/null; then
|
|
102
|
+
rename_branch "$SPECIFIC_BRANCH"
|
|
103
|
+
else
|
|
104
|
+
echo " $SPECIFIC_BRANCH is NOT merged into main. Leaving as-is."
|
|
105
|
+
fi
|
|
106
|
+
else
|
|
107
|
+
# Scan all local branches merged into main
|
|
108
|
+
echo "Scanning for merged branches..."
|
|
109
|
+
merged=$(git branch --merged main | grep -v "^\*" | grep -v "main$" | grep -v "master$" | grep -v "\-\-merged\-" || true)
|
|
110
|
+
|
|
111
|
+
if [[ -z "$merged" ]]; then
|
|
112
|
+
echo " No unrenamed merged branches found. All clean."
|
|
113
|
+
exit 0
|
|
114
|
+
fi
|
|
115
|
+
|
|
116
|
+
while IFS= read -r branch; do
|
|
117
|
+
rename_branch "$branch"
|
|
118
|
+
done <<< "$merged"
|
|
119
|
+
fi
|
|
120
|
+
|
|
121
|
+
echo ""
|
|
122
|
+
echo "Done."
|