Compare commits
1 Commits
release
...
rkiel-mast
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa1ee2b470 |
35
README.md
35
README.md
@@ -26,13 +26,42 @@ cd ~/GitHub/rkiel
|
||||
git clone https://github.com/rkiel/git-utilities.git
|
||||
```
|
||||
|
||||
To update your `.bash_profile` and `.bashrc`.
|
||||
To add the scripts to your path, add the following to `.bash_profile`
|
||||
|
||||
```
|
||||
cd ~/GitHub/rkiel/git-utilities
|
||||
./install/bin/setup --user rkiel
|
||||
export GIT_UTILITIES_BIN="~/GitHub/rkiel/git-utilities/bin"
|
||||
|
||||
export PATH=${GIT_UTILITIES_BIN}:$PATH
|
||||
```
|
||||
|
||||
To enable `bash` tab completion for `git` commands, add the following to `.bash_profile` (OS X) or `.bashrc` (Linux)
|
||||
|
||||
```
|
||||
source ~/GitHub/rkiel/git-utilities/dotfiles/git-completion.bash
|
||||
```
|
||||
|
||||
To enable your `bash` prompt to display repository status, add the following to `.bash_profile` (OS X) or `.bashrc` (Linux).
|
||||
```
|
||||
source ~/GitHub/rkiel/git-utilities/dotfiles/git-prompt.sh
|
||||
```
|
||||
|
||||
Here's a sample prompt that includes the current branch (i.e. `$(__git_ps1 " %s")`)
|
||||
|
||||
```
|
||||
export PS1='[\[\e[0;35m\]\u@\h\[\e[0m\] \[\e[1;34m\]\W\[\e[0;32m\]$(__git_ps1 " %s")\[\e[0m\]]\$ '
|
||||
```
|
||||
|
||||
To include the `bash` aliases and enable tab completion for the `feature` script, add the following to `.bashrc`.
|
||||
|
||||
```
|
||||
source ~/GitHub/rkiel/git-utilities/dotfiles/bashrc
|
||||
```
|
||||
|
||||
If your user id (i.e. `env|grep USER`) is generic, such as `ec2-user` or `centos` or `ubuntu`, set a `FEATURE_USER` environment variable in your `.bash_profile`. Either your `USER` or `FEATURE_USER` should be unique relative to all the users who will be creating feature branches in your git repository.
|
||||
|
||||
```
|
||||
export FEATURE_USER=rkiel
|
||||
```
|
||||
## Documention
|
||||
|
||||
* [See feature](FEATURE.md)
|
||||
|
||||
12
RELEASE.md
12
RELEASE.md
@@ -17,7 +17,7 @@ release help
|
||||
release join version
|
||||
release leave
|
||||
release list
|
||||
release start (major|minor|patch) from version [using master]
|
||||
release start (major|minor|patch) [from] version
|
||||
release tab [pattern]
|
||||
release trash local-branch-confirmation
|
||||
```
|
||||
@@ -42,21 +42,15 @@ release create 1.0.0
|
||||
Create a shared, release candidate branch.
|
||||
|
||||
```bash
|
||||
release start (major|minor|patch) from version [using master]
|
||||
release start (major|minor|patch) [from] version
|
||||
```
|
||||
|
||||
The `version` specified must be an existing official release version. The `major`, `minor`, and `patch` options will increment the new version number accordingly. For example, to create a patch update, the following command will create a `rc1.0.1` release candidate branch. If the optional `using master` is not specified, the release candiate branch will be created from the version tag (e.g. `v1.0.0`). Otherwise, the release candiate branch will be created from `master`. Also, if the repository contains a `package.json` file, the `version` property will automatically be set and committed.
|
||||
The `version` specified must be an existing official release version. The `major`, `minor`, and `patch` options will increment the new version number accordingly. For example, to create a patch update, the following command will create a `rc1.0.1` release candidate branch.
|
||||
|
||||
```bash
|
||||
git checkout master
|
||||
release start patch from 1.0.0
|
||||
```
|
||||
or
|
||||
|
||||
```bash
|
||||
git checkout master
|
||||
release start patch from 1.0.0 from master
|
||||
```
|
||||
|
||||
Once the shared release candidate branch has been created, use `feature` to create and manage personal feature branches.
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require_relative '../lib/setup/commander'
|
||||
|
||||
commander = Setup::Commander.new(ARGV)
|
||||
if commander.valid?
|
||||
commander.execute
|
||||
else
|
||||
commander.help
|
||||
end
|
||||
@@ -1,95 +0,0 @@
|
||||
require 'ostruct'
|
||||
require 'optparse'
|
||||
require 'json'
|
||||
|
||||
require_relative './prompt'
|
||||
|
||||
module Setup
|
||||
|
||||
class Commander
|
||||
|
||||
attr_accessor :options
|
||||
|
||||
def initialize (argv)
|
||||
@options = OpenStruct.new
|
||||
|
||||
@option_parser = OptionParser.new do |op|
|
||||
op.banner = "Usage: setup options"
|
||||
|
||||
op.on('-u','--user USER') do |argument|
|
||||
options.user = argument
|
||||
end
|
||||
|
||||
op.on_tail('-h','--help') do |argument|
|
||||
puts op
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
||||
@option_parser.parse!(argv)
|
||||
options.terms = argv # must be after parse!
|
||||
end
|
||||
|
||||
def valid?
|
||||
options.user
|
||||
end
|
||||
|
||||
def help
|
||||
puts @option_parser
|
||||
exit
|
||||
end
|
||||
|
||||
def execute
|
||||
action = options.action
|
||||
|
||||
|
||||
File.open("#{ENV['HOME']}/.bash_profile", "a") do |f|
|
||||
f.puts
|
||||
f.puts '#############################################################'
|
||||
f.puts "# added by ~/GitHub/rkiel/git-utilities/install/bin/setup"
|
||||
f.puts '#############################################################'
|
||||
f.puts 'export GIT_UTILITIES_BIN="~/GitHub/rkiel/git-utilities/bin"'
|
||||
f.puts 'export PATH=${GIT_UTILITIES_BIN}:$PATH'
|
||||
f.puts 'source ~/GitHub/rkiel/git-utilities/dotfiles/git-completion.bash'
|
||||
f.puts 'source ~/GitHub/rkiel/git-utilities/dotfiles/git-prompt.sh'
|
||||
f.puts "export FEATURE_USER=#{options.user}" if options.user
|
||||
f.puts "export PS1='#{Setup::Prompt.new.generate(options)}'"
|
||||
f.puts '#############################################################'
|
||||
f.puts
|
||||
end
|
||||
|
||||
|
||||
File.open("#{ENV['HOME']}/.bashrc", "a") do |f|
|
||||
f.puts
|
||||
f.puts '#############################################################'
|
||||
f.puts "# added by ~/GitHub/rkiel/git-utilities/install/bin/setup"
|
||||
f.puts '#############################################################'
|
||||
f.puts 'source ~/GitHub/rkiel/git-utilities/dotfiles/bashrc'
|
||||
f.puts '#############################################################'
|
||||
f.puts
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def run_cmd ( cmd )
|
||||
puts
|
||||
puts cmd
|
||||
success = system cmd
|
||||
unless success
|
||||
error "(see above)"
|
||||
end
|
||||
puts
|
||||
end
|
||||
|
||||
def error ( msg )
|
||||
puts
|
||||
puts "ERROR: #{msg}"
|
||||
puts
|
||||
exit
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,114 +0,0 @@
|
||||
module Setup
|
||||
|
||||
class Prompt
|
||||
USERNAME = '\u'
|
||||
ABSOLUTE = '\w'
|
||||
RELATIVE = '\W'
|
||||
PROMPT = '\$'
|
||||
HOSTNAME = '\h'
|
||||
GIT = '$(__git_ps1 " %s")'
|
||||
|
||||
# Reset
|
||||
Color_Off='\e[0m' # Text Reset
|
||||
|
||||
# Regular Colors
|
||||
Black='\e[0;30m' # Black
|
||||
Red='\e[0;31m' # Red
|
||||
Green='\e[0;32m' # Green
|
||||
Yellow='\e[0;33m' # Yellow
|
||||
Blue='\e[0;34m' # Blue
|
||||
Purple='\e[0;35m' # Purple
|
||||
Cyan='\e[0;36m' # Cyan
|
||||
White='\e[0;37m' # White
|
||||
|
||||
# Bold
|
||||
BBlack='\e[1;30m' # Black
|
||||
BRed='\e[1;31m' # Red
|
||||
BGreen='\e[1;32m' # Green
|
||||
BYellow='\e[1;33m' # Yellow
|
||||
BBlue='\e[1;34m' # Blue
|
||||
BPurple='\e[1;35m' # Purple
|
||||
BCyan='\e[1;36m' # Cyan
|
||||
BWhite='\e[1;37m' # White
|
||||
|
||||
# Underline
|
||||
UBlack='\e[4;30m' # Black
|
||||
URed='\e[4;31m' # Red
|
||||
UGreen='\e[4;32m' # Green
|
||||
UYellow='\e[4;33m' # Yellow
|
||||
UBlue='\e[4;34m' # Blue
|
||||
UPurple='\e[4;35m' # Purple
|
||||
UCyan='\e[4;36m' # Cyan
|
||||
UWhite='\e[4;37m' # White
|
||||
|
||||
# Background
|
||||
On_Black='\e[40m' # Black
|
||||
On_Red='\e[41m' # Red
|
||||
On_Green='\e[42m' # Green
|
||||
On_Yellow='\e[43m' # Yellow
|
||||
On_Blue='\e[44m' # Blue
|
||||
On_Purple='\e[45m' # Purple
|
||||
On_Cyan='\e[46m' # Cyan
|
||||
On_White='\e[47m' # White
|
||||
|
||||
# High Intensity
|
||||
IBlack='\e[0;90m' # Black
|
||||
IRed='\e[0;91m' # Red
|
||||
IGreen='\e[0;92m' # Green
|
||||
IYellow='\e[0;93m' # Yellow
|
||||
IBlue='\e[0;94m' # Blue
|
||||
IPurple='\e[0;95m' # Purple
|
||||
ICyan='\e[0;96m' # Cyan
|
||||
IWhite='\e[0;97m' # White
|
||||
|
||||
# Bold High Intensity
|
||||
BIBlack='\e[1;90m' # Black
|
||||
BIRed='\e[1;91m' # Red
|
||||
BIGreen='\e[1;92m' # Green
|
||||
BIYellow='\e[1;93m' # Yellow
|
||||
BIBlue='\e[1;94m' # Blue
|
||||
BIPurple='\e[1;95m' # Purple
|
||||
BICyan='\e[1;96m' # Cyan
|
||||
BIWhite='\e[1;97m' # White
|
||||
|
||||
# High Intensity backgrounds
|
||||
On_IBlack='\e[0;100m' # Black
|
||||
On_IRed='\e[0;101m' # Red
|
||||
On_IGreen='\e[0;102m' # Green
|
||||
On_IYellow='\e[0;103m' # Yellow
|
||||
On_IBlue='\e[0;104m' # Blue
|
||||
On_IPurple='\e[0;105m' # Purple
|
||||
On_ICyan='\e[0;106m' # Cyan
|
||||
On_IWhite='\e[0;107m' # White
|
||||
|
||||
def generate (options)
|
||||
values = []
|
||||
values << '['
|
||||
values << color(Purple)
|
||||
values << USERNAME
|
||||
values << '@'
|
||||
values << HOSTNAME
|
||||
values << color(Color_Off)
|
||||
values << ' '
|
||||
values << color(BBlue)
|
||||
values << RELATIVE
|
||||
values << color(Green)
|
||||
values << GIT
|
||||
values << color(Color_Off)
|
||||
values << ']'
|
||||
values << PROMPT
|
||||
values << ' '
|
||||
|
||||
values.join('')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def color (value)
|
||||
'\['+value+'\]'
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -63,9 +63,6 @@ module Release
|
||||
error "Version branch already exists: #{branch}" if remote_branch(branch) != ""
|
||||
end
|
||||
|
||||
def validate_branch_is_master (branch)
|
||||
error "Branch must be master: #{branch}" if branch != "master"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@ module Release
|
||||
validate_version_format version
|
||||
|
||||
validate_current_branch_master
|
||||
git_fetch_and_merge current_branch
|
||||
git_pull current_branch
|
||||
|
||||
validate_version_is_new version
|
||||
|
||||
update_package_json version, version
|
||||
update_package_json version
|
||||
|
||||
git_local_tag release_tag_from_version(version)
|
||||
|
||||
|
||||
@@ -16,15 +16,18 @@ module Release
|
||||
|
||||
validate_current_branch_is_release
|
||||
|
||||
git_fetch_and_merge release_branch
|
||||
git_pull release_branch
|
||||
|
||||
update_package_json version_from_release_branch(release_branch)
|
||||
|
||||
git_local_tag release_tag_from_version(version_from_release_branch(release_branch))
|
||||
|
||||
git_push release_branch
|
||||
git_push_tags
|
||||
|
||||
git_checkout :master
|
||||
git_fetch_and_merge :master
|
||||
git_checkout "master"
|
||||
|
||||
#git_merge_message release_branch, "merge #{version_from_release_branch(release_branch)}"
|
||||
|
||||
git_local_branch_delete release_branch
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ module Release
|
||||
subcommand, version = *argv
|
||||
|
||||
validate_current_branch_master
|
||||
git_fetch_and_merge current_branch
|
||||
git_pull current_branch
|
||||
|
||||
git_checkout_track release_branch_from_version(version)
|
||||
end
|
||||
|
||||
@@ -4,30 +4,19 @@ module Release
|
||||
|
||||
class Leave < Release::Base
|
||||
def valid?
|
||||
argv.size == 2
|
||||
argv.size == 1
|
||||
end
|
||||
|
||||
def help
|
||||
"release leave local-branch-confirmation"
|
||||
"release leave"
|
||||
end
|
||||
|
||||
def execute
|
||||
if argv.size == 2
|
||||
confirmation_branch = argv[1]
|
||||
else
|
||||
confirmation_branch = ''
|
||||
end
|
||||
|
||||
release_branch = current_branch
|
||||
|
||||
error "Missing confirmation of branch: #{release_branch}" if confirmation_branch == ''
|
||||
error "Confirmation branch does not match current branch: #{confirmation_branch} vs #{release_branch}" if release_branch != confirmation_branch
|
||||
validate_current_branch_is_release
|
||||
|
||||
git_checkout :master
|
||||
git_fetch_and_merge :master
|
||||
git_checkout "master"
|
||||
|
||||
git_local_branch_trash release_branch
|
||||
git_local_branch_trash current_branch
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ module Release
|
||||
|
||||
def execute
|
||||
validate_current_branch_master
|
||||
git_fetch_and_merge current_branch
|
||||
git_pull current_branch
|
||||
|
||||
puts
|
||||
puts show_existing_tags
|
||||
|
||||
@@ -4,27 +4,25 @@ module Release
|
||||
|
||||
class Start < Release::Base
|
||||
def valid?
|
||||
argv.size == 4 or argv.size == 6
|
||||
argv.size == 3 or argv.size == 4
|
||||
end
|
||||
|
||||
def help
|
||||
"release start (major|minor|patch) from version [using master]"
|
||||
"release start (major|minor|patch) [from] version"
|
||||
end
|
||||
|
||||
def execute
|
||||
case argv.size
|
||||
when 3
|
||||
subcommand, level, version = *argv
|
||||
when 4
|
||||
subcommand, level, verb, version = *argv
|
||||
starting_branch = nil
|
||||
when 6
|
||||
subcommand, level, verb, version, verb2, starting_branch = *argv
|
||||
validate_branch_is_master(starting_branch)
|
||||
end
|
||||
|
||||
validate_version_format version
|
||||
|
||||
validate_current_branch_master
|
||||
git_fetch_and_merge current_branch
|
||||
git_pull current_branch
|
||||
|
||||
validate_version_exists version
|
||||
|
||||
@@ -40,16 +38,11 @@ module Release
|
||||
error "unknow release level: #{level}"
|
||||
end
|
||||
|
||||
starting_branch = release_tag_from_version(version) unless starting_branch
|
||||
|
||||
validate_version_does_not_exist new_version
|
||||
validate_release_branch_does_not_exist(release_branch_from_version(new_version))
|
||||
|
||||
git_local_branch_create release_branch_from_version(new_version), starting_branch
|
||||
git_local_branch_create release_branch_from_version(new_version), release_tag_from_version(version)
|
||||
git_push_upstream(release_branch_from_version(new_version))
|
||||
|
||||
update_package_json new_version, "#{new_version} started"
|
||||
git_push(release_branch_from_version(new_version))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -24,8 +24,7 @@ module Release
|
||||
error "Confirmation branch does not match current branch: #{confirmation_branch} vs #{release_branch}" if release_branch != confirmation_branch
|
||||
validate_current_branch_is_release
|
||||
|
||||
git_checkout :master
|
||||
git_fetch_and_merge :master
|
||||
git_checkout 'master'
|
||||
|
||||
git_local_branch_trash release_branch
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ module Shared
|
||||
end
|
||||
|
||||
def standard_branches
|
||||
['master','release']
|
||||
['master']
|
||||
end
|
||||
|
||||
def version_pattern
|
||||
|
||||
@@ -21,14 +21,14 @@ module Shared
|
||||
exit
|
||||
end
|
||||
|
||||
def update_package_json (version, message)
|
||||
def update_package_json (version)
|
||||
if File.exist? 'package.json'
|
||||
package_json = File.read('package.json')
|
||||
json = JSON.parse(package_json)
|
||||
json['version'] = version
|
||||
File.write('package.json', JSON.pretty_generate(json))
|
||||
git_add 'package.json'
|
||||
git_commit message, true
|
||||
git_commit version
|
||||
end
|
||||
end
|
||||
|
||||
@@ -36,6 +36,10 @@ module Shared
|
||||
run_cmd "git add #{path}"
|
||||
end
|
||||
|
||||
def git_commit (msg)
|
||||
run_cmd "git commit -m '#{msg}'"
|
||||
end
|
||||
|
||||
def git_show_branches
|
||||
run_cmd "git branch"
|
||||
end
|
||||
@@ -44,25 +48,6 @@ module Shared
|
||||
run_cmd "git checkout #{branch}"
|
||||
end
|
||||
|
||||
def git_fetch
|
||||
run_cmd "git fetch origin -p && git fetch origin --tags"
|
||||
end
|
||||
|
||||
def git_remote_merge ( branch )
|
||||
run_cmd "git merge origin/#{branch} -m 'merged by release'"
|
||||
end
|
||||
|
||||
def is_remote_branch (branch)
|
||||
`git branch -r|grep origin|grep -v 'HEAD'|grep #{branch}`.strip != ""
|
||||
end
|
||||
|
||||
def git_fetch_and_merge (branch)
|
||||
git_fetch
|
||||
if is_remote_branch(branch)
|
||||
git_remote_merge branch
|
||||
end
|
||||
end
|
||||
|
||||
def git_remote_branch_delete ( branch )
|
||||
run_cmd "git push origin :#{branch}"
|
||||
end
|
||||
@@ -99,6 +84,10 @@ module Shared
|
||||
run_cmd "git merge #{branch}"
|
||||
end
|
||||
|
||||
def git_merge_message (branch, message)
|
||||
run_cmd "git merge -m '#{message}' #{branch}"
|
||||
end
|
||||
|
||||
def git_push (branch)
|
||||
run_cmd "git push origin #{branch}"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user