Skip to content

Commit 81e2db0

Browse files
committed
Merge branch 'hotfix/v5.30.X'
2 parents 7e8a860 + a334092 commit 81e2db0

6 files changed

Lines changed: 159 additions & 55 deletions

File tree

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
# Changelog
44

5+
## 5.30.1-beta.1 (2025-10-02)
6+
7+
_Commits from: v5.30.0..HEAD_
8+
9+
### 📦 gitutils changes
10+
11+
#### Bug Fixes
12+
13+
- 🐛 enhance hotfix branch creation and rebase handling ([c17a3d2](https://github.com/tomgrv/devcontainer-features/commit/c17a3d2e086ce09d83b2d443b433c5d632a96616))
14+
- 🐛 refine version extraction ([9de255e](https://github.com/tomgrv/devcontainer-features/commit/9de255ed621955a6cdaf3793d563e104cff7e13a))
15+
516
## 5.30.0-beta.1 (2025-10-02)
617

718
_Commits from: v5.29.1..HEAD_

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tomgrv/devcontainer-features",
3-
"version": "5.30.0-beta.1",
3+
"version": "5.30.1-beta.1",
44
"description": "Configure dev environment with devcontainer, gitflow, gitversion, git aliases & hooks. Can be used a devcontainer features",
55
"keywords": [
66
"dev",

src/gitutils/_git-release-hotfix.sh

Lines changed: 90 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,105 @@ cd "$(git rev-parse --show-toplevel)" >/dev/null
66
# Parse arguments and print help if needed
77
eval $(
88
zz_args "Create HotFix branch" $0 "$@" <<-help
9+
r - rebase force rebase of current commits onto hotfix branch
910
help
1011
)
1112

1213
#### GET last vX.Y.Z tag on the main branch, removing the leading 'v' and replacing last number with 'X'
13-
current=$(git describe --tags --abbrev=0 --match "v[0-9]*.[0-9]*.[0-9]*" main | sed -e 's/^v//' -e 's/\.[0-9]*$/.X/')
14+
main=$(git describe --tags --abbrev=0 --match "v[0-9]*.[0-9]*.[0-9]*" main)
1415

15-
#### SAVE CURRENT STATUS
16-
git stash --include-untracked --message "Before $current" --keep-index
16+
if [ -z "$main" ]; then
17+
zz_log e "No tag found on main branch"
18+
exit 1
19+
else
20+
zz_log i "Current version is $main"
21+
fi
22+
23+
# Check if all commits since the last tag are conventional commits of 'fix:' type
24+
# or if rebase is forced via command line option
25+
if [ -n "$rebase" ]; then
26+
zz_log i "Rebase forced via command line option, will rebase commits onto hotfix branch"
27+
elif git log "$main"..HEAD --pretty=%B | grep -v -E '^fix(\(.+\))?: ' | grep -E '^[a-zA-Z]' >/dev/null; then
28+
zz_log w "There are commits since $main that are not of type 'fix:', creating hotfix branch and reapplying stash"
29+
rebase=false
30+
else
31+
zz_log i "All commits since $main are of type 'fix:', creating hotfix branch and rebasing current history + stash on top of it"
32+
rebase=true
33+
fi
34+
35+
# If rebase needed, check that develop branch has not been pushed since last tag
36+
if [ -n "$rebase" ]; then
37+
if [ "$(git rev-parse develop)" != "$(git rev-parse origin/develop)" ]; then
38+
zz_log e "Develop branch has been pushed since last tag, cannot rebase safely, aborting"
39+
exit 1
40+
fi
41+
fi
42+
43+
# Ensure working directory is clean
44+
if [ -n "$(git status --porcelain)" ]; then
45+
zz_log e "Working directory is not clean. Please commit or stash changes."
46+
exit 1
47+
fi
1748

1849
#### PREVENT GIT EDITOR PROMPT
1950
GIT_EDITOR=:
2051

52+
current=$(echo "$main" | sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+)/\1.\2.X/')
53+
2154
#### START HOTFIX
2255
git flow hotfix start $current
2356

24-
#### RESTORE STATUS
25-
git stash apply
57+
#### RESTORE STATUS AND HANDLE REBASE
58+
if [ -n "$rebase" ]; then
59+
60+
zz_log i "Rebasing: inverting develop and hotfix branches..."
61+
62+
# Store current branch heads
63+
develop_head=$(git rev-parse develop)
64+
hotfix_head=$(git rev-parse "hotfix/$current")
65+
66+
# Pick all "fix" commits from develop and rebase them onto hotfix branch
67+
zz_log i "Cherry-picking fix commits from develop branch..."
68+
69+
# Get all fix commits from develop since the main tag
70+
fix_commits=$(git log --reverse --pretty=format:"%H" "$main"..develop --grep="^fix")
71+
72+
if [ -n "$fix_commits" ]; then
73+
# Cherry-pick each fix commit onto the hotfix branch
74+
echo "$fix_commits" | while read commit; do
75+
76+
zz_log i "Cherry-picking commit: $(git log --oneline -1 $commit)"
77+
if ! git cherry-pick "$commit"; then
78+
zz_log e "Failed to cherry-pick commit $commit"
79+
zz_log i "Please resolve conflicts and run 'git cherry-pick --continue'"
80+
exit 1
81+
fi
82+
done
83+
zz_log s "Successfully cherry-picked all fix commits"
84+
85+
# Now, remove the fix commits on develop branch that are now on hotfix
86+
echo "$fix_commits" | while read commit; do
87+
88+
if ! git checkout develop && git revert --no-commit "$commit"; then
89+
zz_log e "Failed to revert commit $commit on develop"
90+
exit 1
91+
fi
92+
93+
done
94+
95+
96+
else
97+
zz_log i "No fix commits found to cherry-pick"
98+
fi
99+
100+
# Reset develop branch to the main tag (removing the fix commits that are now on hotfix)
101+
git checkout develop
102+
git reset --hard "$main"
103+
zz_log i "Reset develop branch to $main"
104+
105+
# Return to hotfix branch
106+
git checkout "hotfix/$current"
107+
108+
zz_log s "Successfully inverted develop and hotfix branches"
109+
fi
110+

src/gitutils/_git-release-prod.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ cd "$(git rev-parse --show-toplevel)" >/dev/null
1212
# Check if on a hotfix branch and extract branch name
1313
if [ -n "$(git branch --list hotfix/*)" ]; then
1414
flow=hotfix
15-
name=$(git branch --list hotfix/* | sed 's/.*hotfix\///')
15+
name=$(git branch --list hotfix/* | sed 's/.*hotfix\///'| head -n1 )
1616
zz_log i "Hotfix branch found: {Yellow $name}"
1717
fi
1818

1919
# Check if on a release branch and extract branch name
2020
if [ -n "$(git branch --list release/*)" ]; then
2121
flow=release
22-
name=$(git branch --list release/* | sed 's/.*release\///')
22+
name=$(git branch --list release/* | sed 's/.*release\///' | head -n1 )
2323
zz_log i "Release branch found: {Blue $name}"
2424
fi
2525

@@ -37,12 +37,18 @@ if [ -z "$flow" ] || [ -z "$name" ]; then
3737
fi
3838

3939
# Extract branch name
40-
if ! git checkout $flow/$name; then
40+
if ! git checkout $flow/$name >/dev/null 2>&1; then
4141
zz_log e "Cannot switch to $flow/$name branch"
4242
exit 1
4343
fi
4444
zz_log s "On branch: {Blue $flow/$name}"
4545

46+
# Ensure working directory is clean
47+
if [ -n "$(git status --porcelain)" ]; then
48+
zz_log e "Working directory is not clean. Please commit or stash changes."
49+
exit 1
50+
fi
51+
4652
# Get the new version from gitversion
4753
GBV=$(gv -showvariable MajorMinorPatch)
4854
if [ -z "$GBV" ]; then
@@ -55,7 +61,7 @@ zz_log i "Bump version: {Blue $GBV}"
5561
GIT_EDITOR=:
5662

5763
# Update version, changelog, and finish release
58-
if bump-changelog -f $GBV -b -m; then
64+
if bump-changelog -f $GBV -b; then
5965
zz_log s "Version & CHANGELOG updated to: {B $GBV}"
6066
if ! git commit -am "chore(release): $GBV"; then
6167
zz_log e "Cannot commit version & CHANGELOG"
@@ -68,6 +74,9 @@ if bump-changelog -f $GBV -b -m; then
6874
if git flow $flow finish $name --push --tagname $GBV --message $GBV ; then
6975
zz_log s "Release finished: {B $GBV}"
7076
rm -f .git/RELEASE
77+
78+
# Create git tag for the new version
79+
bump-tag $GBV
7180
else
7281
git undo
7382
zz_log e "Cannot finish release. CHANGELOG & VERSION are not updated."
@@ -76,5 +85,4 @@ else
7685
zz_log e "Cannot update version & finish release"
7786
fi
7887

79-
# Follow major/minor tags
80-
bump-tag $GBV
88+

src/gitutils/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "gitutils",
33
"name": "Git Aliases",
44
"description": "A feature to add useful Git aliases to your shell.",
5-
"version": "5.30.0-beta.1",
5+
"version": "5.30.1-beta.1",
66
"dependsOn": {
77
"ghcr.io/devcontainers/features/node:1": "lts",
88
"ghcr.io/tomgrv/devcontainer-features/common-utils:5": {

src/gitutils/package.json

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
{
2-
"name": "@tomgrv/gitutils",
3-
"version": "5.30.0-beta.1",
4-
"description": "Git utilities and aliases for development workflow",
5-
"files": [
6-
"_*.sh",
7-
"install.sh",
8-
"install-config.sh",
9-
"alias.json",
10-
"config.json",
11-
"stubs/**/*"
12-
],
13-
"bin": {
14-
"deleteChildren": "./_deleteChildren.sh",
15-
"git-align": "./_git-align.sh",
16-
"git-co": "./_git-co.sh",
17-
"git-degit": "./_git-degit.sh",
18-
"git-fix": "./_git-fix.sh",
19-
"git-fix-author": "./_git-fix-author.sh",
20-
"git-fix-emoji": "./_git-fix-emoji.sh",
21-
"git-fix-last": "./_git-fix-last.sh",
22-
"git-fix-lock": "./_git-fix-lock.sh",
23-
"git-fix-mode": "./_git-fix-mode.sh",
24-
"git-fix-privacy": "./_git-fix-privacy.sh",
25-
"git-fix-up": "./_git-fix-up.sh",
26-
"git-forall": "./_git-forall.sh",
27-
"git-getcommit": "./_git-getcommit.sh",
28-
"git-integrate": "./_git-integrate.sh",
29-
"git-pick": "./_git-pick.sh",
30-
"git-release": "./_git-release.sh",
31-
"git-release-alpha": "./_git-release-alpha.sh",
32-
"git-release-beta": "./_git-release-beta.sh",
33-
"git-release-hotfix": "./_git-release-hotfix.sh",
34-
"git-release-prod": "./_git-release-prod.sh",
35-
"setrights": "./_setrights.sh",
36-
"unset": "./_unset.sh"
37-
},
38-
"scripts": {},
39-
"dependencies": {},
40-
"peerDependencies": {
41-
"@tomgrv/common-utils": "^5.0.0",
42-
"@tomgrv/gitversion": "^5.0.0"
43-
}
2+
"name": "@tomgrv/gitutils",
3+
"version": "5.30.1-beta.1",
4+
"description": "Git utilities and aliases for development workflow",
5+
"files": [
6+
"_*.sh",
7+
"install.sh",
8+
"install-config.sh",
9+
"alias.json",
10+
"config.json",
11+
"stubs/**/*"
12+
],
13+
"bin": {
14+
"deleteChildren": "./_deleteChildren.sh",
15+
"git-align": "./_git-align.sh",
16+
"git-co": "./_git-co.sh",
17+
"git-degit": "./_git-degit.sh",
18+
"git-fix": "./_git-fix.sh",
19+
"git-fix-author": "./_git-fix-author.sh",
20+
"git-fix-emoji": "./_git-fix-emoji.sh",
21+
"git-fix-last": "./_git-fix-last.sh",
22+
"git-fix-lock": "./_git-fix-lock.sh",
23+
"git-fix-mode": "./_git-fix-mode.sh",
24+
"git-fix-privacy": "./_git-fix-privacy.sh",
25+
"git-fix-up": "./_git-fix-up.sh",
26+
"git-forall": "./_git-forall.sh",
27+
"git-getcommit": "./_git-getcommit.sh",
28+
"git-integrate": "./_git-integrate.sh",
29+
"git-pick": "./_git-pick.sh",
30+
"git-release": "./_git-release.sh",
31+
"git-release-alpha": "./_git-release-alpha.sh",
32+
"git-release-beta": "./_git-release-beta.sh",
33+
"git-release-hotfix": "./_git-release-hotfix.sh",
34+
"git-release-prod": "./_git-release-prod.sh",
35+
"setrights": "./_setrights.sh",
36+
"unset": "./_unset.sh"
37+
},
38+
"scripts": {},
39+
"dependencies": {},
40+
"peerDependencies": {
41+
"@tomgrv/common-utils": "^5.0.0",
42+
"@tomgrv/gitversion": "^5.0.0"
43+
}
4444
}

0 commit comments

Comments
 (0)