Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitflow
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tools
gitflow
Commits
ab4b80d5
Commit
ab4b80d5
authored
Jan 25, 2010
by
Vincent Driessen
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ensure-clean-env' into develop
parents
7d0a4096
3d412555
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
164 additions
and
20 deletions
+164
-20
gitflow-feature
gitflow-feature
+17
-2
gitflow-hotfix
gitflow-hotfix
+22
-8
gitflow-release
gitflow-release
+22
-9
gitflow-sh-setup
gitflow-sh-setup
+90
-1
test-sh-setup
test-sh-setup
+13
-0
No files found.
gitflow-feature
View file @
ab4b80d5
...
@@ -32,17 +32,32 @@ parse_args() {
...
@@ -32,17 +32,32 @@ parse_args() {
}
}
start
()
{
start
()
{
# TODO
parse_args
"
$@
"
parse_args
"
$@
"
# Checks
gitflow_check_clean_working_tree
gitflow_check_clean_working_tree
gitflow_require_branch_absent
"
$FEATURE
"
if
[
"
$BASE
"
=
"develop"
]
;
then
gitflow_require_branches_equal
'develop'
'origin/develop'
fi
# All checks passed, ready to roll
echo
"git checkout -b
$FEATURE
$BASE
"
echo
"git checkout -b
$FEATURE
$BASE
"
}
}
finish
()
{
finish
()
{
# TODO
parse_args
"
$@
"
parse_args
"
$@
"
# Checks
gitflow_check_clean_working_tree
gitflow_check_clean_working_tree
gitflow_require_branch
"
$FEATURE
"
if
[
"
$BASE
"
=
"develop"
]
;
then
gitflow_require_branches_equal
'develop'
'origin/develop'
fi
# All checks passed, ready to roll
echo
"git checkout
$BASE
"
echo
"git checkout
$BASE
"
echo
"git merge --no-ff
$FEATURE
"
echo
"git merge --no-ff
$FEATURE
"
echo
"git branch -d
$FEATURE
"
}
}
gitflow-hotfix
View file @
ab4b80d5
...
@@ -24,25 +24,39 @@ parse_args() {
...
@@ -24,25 +24,39 @@ parse_args() {
usage
usage
exit
1
exit
1
fi
fi
HOTFIX_BRANCH
=
"hotfix-
$RELEASE
"
}
}
start
()
{
start
()
{
# TODO
parse_args
"
$@
"
parse_args
"
$@
"
# Checks
gitflow_check_clean_working_tree
gitflow_check_clean_working_tree
echo
"git checkout -b hotfix-
$RELEASE
master"
gitflow_require_branches_equal
'master'
'origin/master'
echo
"Bump version number"
gitflow_require_branch_absent
"
$HOTFIX_BRANCH
"
echo
"Fix bug"
# All checks passed, ready to roll
echo
"git checkout -b
\"
$HOTFIX_BRANCH
\"
master"
echo
"Don't forget to bump the version number now."
}
}
finish
()
{
finish
()
{
# TODO
parse_args
"
$@
"
parse_args
"
$@
"
# Checks
gitflow_check_clean_working_tree
gitflow_check_clean_working_tree
echo
"git fetch origin"
git fetch origin
gitflow_require_branches_equal
'master'
'origin/master'
gitflow_require_branches_equal
'develop'
'origin/develop'
# All checks passed, ready to roll
echo
"git checkout master"
echo
"git checkout master"
echo
"git merge --no-ff hotfix-
$RELEASE
"
echo
"git merge --no-ff
\"
$HOTFIX_BRANCH
\"
"
echo
"git tag
\"
$RELEASE
\"
"
echo
"git checkout develop"
echo
"git checkout develop"
echo
"git merge --no-ff
hotfix-
$RELEASE
"
echo
"git merge --no-ff
\"
$HOTFIX_BRANCH
\"
"
echo
"git branch -d
hotfix-
$RELEASE
"
echo
"git branch -d
\"
$HOTFIX_BRANCH
\"
"
}
}
gitflow-release
View file @
ab4b80d5
...
@@ -24,26 +24,39 @@ parse_args() {
...
@@ -24,26 +24,39 @@ parse_args() {
usage
usage
exit
1
exit
1
fi
fi
RELEASE_BRANCH
=
"release-
$RELEASE
"
}
}
start
()
{
start
()
{
# TODO
parse_args
"
$@
"
parse_args
"
$@
"
# Checks
gitflow_check_clean_working_tree
gitflow_check_clean_working_tree
echo
"git checkout -b release-
$RELEASE
develop"
gitflow_require_branches_equal
'develop'
'origin/develop'
echo
"Bump version number"
gitflow_require_branch_absent
"
$RELEASE_BRANCH
"
echo
"Fix bug"
# All checks passed, ready to roll
echo
"git checkout -b
\"
$RELEASE_BRANCH
\"
develop"
echo
"Don't forget to bump the version number now."
}
}
finish
()
{
finish
()
{
# TODO
parse_args
"
$@
"
parse_args
"
$@
"
# Checks
gitflow_check_clean_working_tree
gitflow_check_clean_working_tree
echo
"git fetch origin"
git fetch origin
gitflow_require_branches_equal
'master'
'origin/master'
gitflow_require_branches_equal
'develop'
'origin/develop'
# All checks passed, ready to roll
echo
"git checkout master"
echo
"git checkout master"
echo
"git merge --no-ff
release-
$RELEASE
"
echo
"git merge --no-ff
\"
$RELEASE_BRANCH
\"
"
echo
"git tag
$RELEASE
"
echo
"git tag
\"
$RELEASE
\"
"
echo
"git checkout develop"
echo
"git checkout develop"
echo
"git merge --no-ff
release-
$RELEASE
"
echo
"git merge --no-ff
\"
$RELEASE_BRANCH
\"
"
echo
"git branch -d
release-
$RELEASE
"
echo
"git branch -d
\"
$RELEASE_BRANCH
\"
"
}
}
gitflow-sh-setup
View file @
ab4b80d5
...
@@ -12,7 +12,96 @@
...
@@ -12,7 +12,96 @@
# Copyright (c) 2010 by Vincent Driessen
# Copyright (c) 2010 by Vincent Driessen
#
#
# Get the git dir
GIT_DIR
=
$(
git rev-parse
--git-dir
)
# Get all available branches
LOCAL_BRANCHES
=
$(
cd
"
$GIT_DIR
/refs/heads"
;
find
*
-type
f
)
REMOTE_BRANCHES
=
$(
cd
"
$GIT_DIR
/refs/remotes"
;
find
*
-type
f
)
ALL_BRANCHES
=
"
$LOCAL_BRANCHES
\n
$REMOTE_BRANCHES
"
warn
()
{
echo
"
$@
"
>
&2
;
}
die
()
{
warn
"
$@
"
;
exit
1
;
}
gitflow_check_clean_working_tree
()
{
gitflow_check_clean_working_tree
()
{
echo
"Working tree
$(
pwd
)
clean."
if
[
"
$(
git status 2> /dev/null |
tail
-n1
)
"
!=
"nothing to commit (working directory clean)"
]
;
then
die
"Working directory is dirty. Only use gitflow in clean working directories for your own safety."
fi
}
gitflow_require_local_branch
()
{
echo
"
$LOCAL_BRANCHES
"
|
grep
"^
$1
\$
"
2>/dev/null
>
/dev/null
if
[
$?
-ne
0
]
;
then
die
"Local branch '
$1
' does not exist and is required."
fi
}
gitflow_require_remote_branch
()
{
echo
"
$REMOTE_BRANCHES
"
|
grep
"^
$1
\$
"
2>/dev/null
>
/dev/null
if
[
$?
-ne
0
]
;
then
die
"Remote branch '
$1
' does not exist and is required."
fi
}
gitflow_require_branch
()
{
echo
"
$ALL_BRANCHES
"
|
grep
"^
$1
\$
"
2>/dev/null
>
/dev/null
if
[
$?
-ne
0
]
;
then
die
"Branch '
$1
' does not exist and is required."
fi
}
gitflow_require_branch_absent
()
{
echo
"
$ALL_BRANCHES
"
|
grep
"^
$1
\$
"
2>/dev/null
>
/dev/null
if
[
$?
-eq
0
]
;
then
die
"Branch '
$1
' already exists."
fi
}
#
# gitflow_test_branches_equal()
#
# Tests whether branches and their "origin" counterparts have diverged and need
# merging first. It returns error codes to provide more detail, like so:
#
# 0 Branch heads point to the same commit
# 1 First given branch needs fast-forwarding
# 2 Second given branch needs fast-forwarding
# 3 Branch needs a real merge
#
gitflow_test_branches_equal
()
{
commit1
=
$(
git rev-parse
"
$1
"
)
commit2
=
$(
git rev-parse
"
$2
"
)
if
[
"
$commit1
"
!=
"
$commit2
"
]
;
then
base
=
$(
git merge-base
"
$commit1
"
"
$commit2
"
)
short_base
=
$(
git rev-parse
--short
"
$base
"
)
if
[
"
$commit1
"
=
"
$base
"
]
;
then
return
1
elif
[
"
$commit2
"
=
"
$base
"
]
;
then
return
2
else
return
3
fi
else
return
0
fi
}
gitflow_require_branches_equal
()
{
gitflow_require_local_branch
"
$1
"
gitflow_require_remote_branch
"
$2
"
gitflow_test_branches_equal
"
$1
"
"
$2
"
status
=
$?
if
[
$status
-gt
0
]
;
then
warn
"Branches '
$1
' and '
$2
' have diverged."
if
[
$status
-eq
1
]
;
then
die
"And branch '
$1
' may be fast-forwarded."
elif
[
$status
-eq
2
]
;
then
die
"And local branch '
$1
' is ahead of '
$2
'."
else
die
"Branches need merging first."
fi
fi
}
}
test-sh-setup
0 → 100755
View file @
ab4b80d5
#!/bin/sh
.
gitflow-sh-setup
gitflow_require_branch
'master'
gitflow_require_branch
'develop'
gitflow_require_branch
'origin/develop'
gitflow_require_branch
'origin/master'
gitflow_require_branches_equal
'master'
'origin/master'
gitflow_require_branches_equal
'develop'
'origin/develop'
gitflow_require_branches_equal
'rebase-not-merge'
'truemped/rebase-not-merge'
echo
"All OK."
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment