Skip to content

Commit

Permalink
- Added update to release
Browse files Browse the repository at this point in the history
- Added ZSH to install_completion make task
  • Loading branch information
mrkmg committed May 7, 2018
1 parent 319e966 commit 298b201
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 25 deletions.
24 changes: 16 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
VERSION = 0.7.2
VERSION = 0.7.2

PREFIX ?= /usr/local
PREFIX ?= /usr/local
DEST_BIN_DIR = $(PREFIX)/bin
DEST_BASH_COMPLETION_DIR = /etc/bash_completion.d
SOURCE_BIN_DIR = ./bin/
SOURCE_SUPPORT_DIR = ./support/
LOADER = git-stream
COMPLETION_BASH = git-stream-completion.bash
DEST_BASH_COMPLETION_DIR = /etc/bash_completion.d
DEST_ZSH_COMPLETION_DIR = /usr/share/zsh/site-functions
SOURCE_BIN_DIR = ./bin/
SOURCE_SUPPORT_DIR = ./support/
LOADER = git-stream
COMPLETION_BASH = git-stream-completion.bash
COMPLETION_ZSH = git-stream-completion.zsh
COMMANDS = git-stream-init
COMMANDS += git-stream-feature
COMMANDS += git-stream-feature-start
Expand Down Expand Up @@ -40,8 +42,14 @@ uninstall:

install_completion:
test -d $(DEST_BASH_COMPLETION_DIR) && \
cd $(SOURCE_SUPPORT_DIR) && install -m 0644 -T $(COMPLETION_BASH) $(DEST_BASH_COMPLETION_DIR)/git-stream
cd $(SOURCE_SUPPORT_DIR) && install -m 0644 -T $(COMPLETION_BASH) $(DEST_BASH_COMPLETION_DIR)/git-stream || true

test -d $(DEST_ZSH_COMPLETION_DIR) && \
cd $(SOURCE_SUPPORT_DIR) && install -m 0644 -T $(COMPLETION_ZSH) $(DEST_ZSH_COMPLETION_DIR)/_git-stream || true

uninstall_completion:
test -d $(DEST_BASH_COMPLETION_DIR) && \
rm -f $(DEST_BASH_COMPLETION_DIR)/git-stream

test -d $(DEST_ZSH_COMPLETION_DIR) && \
rm -f $(DEST_ZSH_COMPLETION_DIR)/_git-stream
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ Example Installation on Linux
git clone https://github.com/mrkmg/git-stream.git /tmp/git-stream
cd /tmp/git-stream
git submodule update --init --recursive
git checkout v0.7.2
#checkout latest release
git checkout $(git describe --abbrev=0 --tags)
make test
sudo make install
# To install the bash completion
# To install the bash and zsh completion
sudo make install_completion

By default, Git Stream will be installed to `/usr/local/bin`. If you would prefer to install somewhere else, you can
Expand Down Expand Up @@ -115,6 +116,7 @@ Work with releases. Releases are used to mark specific versions.
start {version}
finish [-l -m {message} -n -d] {version}
list
update

-m, --message {message} A message for the merge (Implies -n)
-n, --no-ff Force a non fast-forward merge
Expand Down Expand Up @@ -156,8 +158,8 @@ So lets say you want to implement a new feature. Run the following:
git stream feature start new-feature

In the above command, "new-feature" is the name of the new feature. This will create a new branch named
"feature/new-feature" forked from master. This is where you would implement your new feature and put you into that
branch.
"feature/new-feature" forked from master and put you into that branch. This is where you would implement
your new feature.

Feel free to switch back to master, or any other branch. Your branch will stay there and allow you to come back and work
on the new feature anytime.
Expand Down Expand Up @@ -203,16 +205,18 @@ This should not have any conflicts, but if it does you can rebase like you did w
release back into master and create a tag for the version. It will also push both your master branch and the new tags
up to origin.

git stream release update 1.1.0

The last feature is the hotfix. Lets say some time goes by, you have committed to master a few times, started a couple
new features, but then a bug is reported that needs an immediate fix. This is where Hot Fixes come into play. If back in
version 1.1.0 a critical bug was introduced. We would want the release a version 1.1.1 which addresses this bug.
version 1.1.0 a critical bug was introduced, we would want the release a version 1.1.1 which addresses this bug.

To make that fix, you start the hotfix.

git stream hotfix start 1.1.0 security-flaw-bug

This will create a branch named "hotfix/1.1.0-security-flaw-bug" forked from the tag 1.1.0. Fix the bug and then finish
the hotfix, and implementing it in 1.1.1.
the hotfix, and implement it in 1.1.1.

git stream hotfix finish 1.1.0-security-flaw-bug 1.1.1

Expand Down
1 change: 1 addition & 0 deletions bin/git-stream-release
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ usage() {
echo "start {version}"
echo "finish [-m {message} | -n | -l | -p] {version}"
echo "list"
echo "update {version}"
echo
echo "-m, --message {message} A message for the merge (Implies -n)"
echo "-n, --no-ff Force a non fast-forward merge"
Expand Down
38 changes: 38 additions & 0 deletions bin/git-stream-release-update
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash

gitstream_release_update() {
local version prefixed_version branch merge_args

if [ $# -ne 1 ]; then
usage; exit 1;
fi

version="$1"

if [ ${version:0:${#VERSION_PREFIX}} = ${VERSION_PREFIX} ]; then
prefixed_version="${version}"
else
prefixed_version="${VERSION_PREFIX}${version}"
fi

branch="${RELEASE_PREFIX}${prefixed_version}"

gitstream_run_hook_die pre release update "${version}" "${branch}" "${WORKING_BRANCH}"

if ! git_working_dir_clean; then
print_error "Working directory is not clean. Please commit or stash your changes before proceeding"
fi

gitstream_checkout_branch "${WORKING_BRANCH}"

git_pull

gitstream_checkout_branch "${branch}"

do_git rebase "${WORKING_BRANCH}"

gitstream_run_hook post release update "${version}" "${branch}" "${WORKING_BRANCH}"

echo
echo "The ${branch} is now up to date with ${WORKING_BRANCH}."
}
2 changes: 1 addition & 1 deletion support/git-stream-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ __git_stream_feature ()

__git_stream_release ()
{
local subcommands="list start finish help"
local subcommands="list start finish update help"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
Expand Down
5 changes: 3 additions & 2 deletions support/git-stream-completion.zsh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!zsh
#
#compdef git-stream
#autoload
# Author: Copyright 2016 Kevin Gravier
#
# Original Author: Copyright 2012-2013 Peter van der Does.
Expand Down Expand Up @@ -80,6 +80,7 @@ __git-stream-release ()
'start:Start a new release branch.'
'finish:Finish a release branch.'
'list:List all your release branches.'
'update:Rebase a release branch to master.'
)
_describe -t commands 'git stream release' subcommands
;;
Expand Down
4 changes: 2 additions & 2 deletions support/hooks/post-stream-release-finish
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# Run after a release is finished
#
# Arguments:
# $1 release-name
# $1 version
# $2 release-branch
# $3 working-branch

NAME=$1
VERSION=$1
BRANCH=$2
WORKING=$3

Expand Down
4 changes: 2 additions & 2 deletions support/hooks/post-stream-release-start
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# Run after a release is started
#
# Arguments:
# $1 release-name
# $1 version
# $2 release-branch
# $3 working-branch

NAME=$1
VERSION=$1
BRANCH=$2
WORKING=$3

Expand Down
16 changes: 16 additions & 0 deletions support/hooks/post-stream-release-update
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
#
# Run after a release is updated
#
# Arguments:
# $1 version
# $2 feature-branch
# $3 working-branch

VERSION=$1
BRANCH=$2
WORKING=$3

# Implement Script Here

exit 0
4 changes: 2 additions & 2 deletions support/hooks/pre-stream-release-finish
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
# If this scripts exits with a non-zero code, the operation is canceled
#
# Arguments:
# $1 release-name
# $1 version
# $2 release-branch
# $3 working-branch

NAME=$1
VERSION=$1
BRANCH=$2
WORKING=$3

Expand Down
4 changes: 2 additions & 2 deletions support/hooks/pre-stream-release-start
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
# If this scripts exits with a non-zero code, the operation is canceled
#
# Arguments:
# $1 release-name
# $1 version
# $2 release-branch
# $3 working-branch

NAME=$1
VERSION=$1
BRANCH=$2
WORKING=$3

Expand Down
17 changes: 17 additions & 0 deletions support/hooks/pre-stream-release-update
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
#
# Run before a release branch is updated
# If this scripts exits with a non-zero code, the operation is canceled
#
# Arguments:
# $1 feature-name
# $2 feature-branch
# $3 working-branch

NAME=$1
BRANCH=$2
WORKING=$3

# Implement Script Here

exit 0
10 changes: 10 additions & 0 deletions tests/specs/release.bats
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,13 @@ teardown() {

[ "${release_branches}" == "${expected_branches}" ]
}

@test "RELEASE: update" {
populate_example_branches
run git checkout master
make_change update1
run git stream release update 0.0.1

git rev-parse "release/v0.0.1"
[ "$(git --no-pager log -1 --pretty=%B --decorate=short | head -n 1)" == "update1" ]
}

0 comments on commit 298b201

Please sign in to comment.