git_dj 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in git-dj.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Mikhail Tabunov
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # Git::Dj
2
+ # Git Dj - is an simple lightweight alternative for git flow. See, how it works:
3
+
4
+ **gdj integrate** – merges current branch into staging branch, executes git push origin staging and switches back to current branch
5
+ **gdj release** merges current branch into master branch, pushes changes and switches back to current branch
6
+
7
+ If you want to start new feature:
8
+
9
+ git checkout master
10
+ git checkout -b my_super_cool_feature_branch
11
+
12
+ If you want deploy it into staging use:
13
+
14
+ gdj integrate
15
+ cap staging deploy
16
+
17
+ If you want to finish feature:
18
+
19
+ gdj release
20
+ cap production deploy
21
+
22
+ Keep your workflow simple.
23
+
24
+ ## Contributing
25
+
26
+ 1. Fork it
27
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
28
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
29
+ 4. Push to the branch (`git push origin my-new-feature`)
30
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/bin/gdj ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path('lib/git_dj.rb')
3
+ gdj = GitDj.new
4
+ gdj.perform
5
+
data/git_dj.gemspec ADDED
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/git_dj/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Mikhail Tabunov"]
6
+ gem.email = ["mikhail@tabunov.ru"]
7
+ gem.description = %q{A simple and lightweight alternative to git flow}
8
+ gem.summary = %q{Git dj<D-d>}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "git_dj"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = GitDj::VERSION
17
+ end
@@ -0,0 +1,3 @@
1
+ class GitDj
2
+ VERSION = "0.0.1"
3
+ end
data/lib/git_dj.rb ADDED
@@ -0,0 +1,99 @@
1
+ class GitDj
2
+ require 'git_dj/version'
3
+ INTEGRATION_BRANCH = 'staging'
4
+ RELEASE_BRANCH = 'master'
5
+
6
+ def initialize
7
+ end
8
+
9
+ def perform
10
+ case ARGV[0]
11
+ when 'integrate'
12
+ integrate_current_branch
13
+ when 'release'
14
+ release_current_branch
15
+ when 'help'
16
+ print_help
17
+ else
18
+ print_help
19
+ end
20
+ end
21
+
22
+ def integrate_current_branch
23
+ cur_branch = current_branch_name
24
+ if has_uncommited_changes
25
+ puts red_color("Failed to integrate #{cur_branch}: you have uncommited changes")
26
+ elsif cur_branch == INTEGRATION_BRANCH
27
+ puts red_color("Can not integrate #{INTEGRATION_BRANCH} into #{INTEGRATION_BRANCH}")
28
+ else
29
+ run_cmds [
30
+ "git checkout #{INTEGRATION_BRANCH}",
31
+ "git merge #{cur_branch}",
32
+ "git push origin #{INTEGRATION_BRANCH}",
33
+ "git checkout #{cur_branch}"
34
+ ]
35
+
36
+ puts green_color("Successfully integrated #{cur_branch}")
37
+ end
38
+ end
39
+
40
+ def release_current_branch
41
+ cur_branch = current_branch_name
42
+ if has_uncommited_changes
43
+ puts red_color("Failed to release #{cur_branch}: you have uncommited changes")
44
+ elsif cur_branch == RELEASE_BRANCH || cur_branch == INTEGRATION_BRANCH
45
+ puts red_color("Can not integrate #{cur_branch} into #{RELEASE_BRANCH}")
46
+ else
47
+ run_cmds [
48
+ "git checkout #{RELEASE_BRANCH}",
49
+ "git merge #{cur_branch}",
50
+ "git push origin #{RELEASE_BRANCH}",
51
+ "git checkout #{cur_branch}"
52
+ ]
53
+
54
+ puts green_color("Successfully released #{cur_branch}")
55
+ end
56
+ end
57
+
58
+ def current_branch_name
59
+ out = %x[git branch]
60
+ branch_string = out.split("\n").detect do |str|
61
+ str.index('*') == 0
62
+ end
63
+
64
+
65
+ branch_string.gsub!(/^\*/, '')
66
+ branch_string.chomp.strip
67
+ end
68
+
69
+ def print_help
70
+ puts %Q{Git DJ #{VERSION}
71
+
72
+ Usage:
73
+ #{green_color('gdj integrate')} - merge current branch in staging branch, and switch back
74
+ #{green_color('gdj release')} - merge current branch into master, and switch back
75
+
76
+ }
77
+ end
78
+
79
+ private
80
+ def has_uncommited_changes
81
+ %x[git diff].chomp.strip != ''
82
+ end
83
+
84
+ def run_cmds(cmds)
85
+ cmds.each do |cmd|
86
+ system(cmd)
87
+ end
88
+ end
89
+
90
+ def red_color(str)
91
+ "\e[0;31m#{str}\e[m"
92
+ end
93
+
94
+ def green_color(str)
95
+ "\e[0;32m#{str}\e[m"
96
+ end
97
+
98
+ end
99
+
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git_dj
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mikhail Tabunov
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-09 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A simple and lightweight alternative to git flow
15
+ email:
16
+ - mikhail@tabunov.ru
17
+ executables:
18
+ - gdj
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - LICENSE
25
+ - README.md
26
+ - Rakefile
27
+ - bin/gdj
28
+ - git_dj.gemspec
29
+ - lib/git_dj.rb
30
+ - lib/git_dj/version.rb
31
+ homepage: ''
32
+ licenses: []
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubyforge_project:
51
+ rubygems_version: 1.8.24
52
+ signing_key:
53
+ specification_version: 3
54
+ summary: Git dj<D-d>
55
+ test_files: []