git_dj 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/LICENSE +3 -1
  2. data/README.md +25 -0
  3. data/lib/git_dj/version.rb +1 -1
  4. data/lib/git_dj.rb +59 -1
  5. metadata +2 -2
data/LICENSE CHANGED
@@ -1,4 +1,5 @@
1
1
  Copyright (c) 2012 Mikhail Tabunov
2
+ blablabla
2
3
 
3
4
  MIT License
4
5
 
@@ -19,4 +20,5 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
20
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
21
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
22
  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.
23
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ blblblblbl
data/README.md CHANGED
@@ -19,6 +19,31 @@ If you want to finish feature:
19
19
  gdj release
20
20
  cap production deploy
21
21
 
22
+ Integrate and Release should fail, if git merge failes. In this case,
23
+ resolve conflits and type:
24
+
25
+ gdj continue
26
+
27
+
28
+ This will proceed all previous commands.
29
+
30
+ If you want to push to remote branch:
31
+
32
+ gdj put
33
+
34
+ And this will execute:
35
+
36
+ git pull origin [branch_name]
37
+ git push origin [branch_name]
38
+
39
+ If you want to pull remote branche, run:
40
+
41
+ gdj get
42
+
43
+ And this will execute:
44
+
45
+ git pull origin [branch_name]
46
+
22
47
  Keep your workflow simple.
23
48
 
24
49
  ## Contributing
@@ -1,3 +1,3 @@
1
1
  class GitDj
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/git_dj.rb CHANGED
@@ -2,6 +2,9 @@ class GitDj
2
2
  require 'git_dj/version'
3
3
  INTEGRATION_BRANCH = 'staging'
4
4
  RELEASE_BRANCH = 'master'
5
+ LOG_FILE_NAME = '/tmp/gdj_activity'
6
+
7
+ class CommandFailedError < StandardError; end;
5
8
 
6
9
  def initialize
7
10
  end
@@ -12,6 +15,12 @@ class GitDj
12
15
  integrate_current_branch
13
16
  when 'release'
14
17
  release_current_branch
18
+ when 'get'
19
+ get_updates_from_origin
20
+ when 'put'
21
+ push_updates_to_origin
22
+ when 'continue'
23
+ continue_prev_commands
15
24
  when 'help'
16
25
  print_help
17
26
  else
@@ -20,6 +29,7 @@ class GitDj
20
29
  end
21
30
 
22
31
  def integrate_current_branch
32
+ drop_commands_cache
23
33
  cur_branch = current_branch_name
24
34
  if has_uncommited_changes
25
35
  puts red_color("Failed to integrate #{cur_branch}: you have uncommited changes")
@@ -38,6 +48,7 @@ class GitDj
38
48
  end
39
49
 
40
50
  def release_current_branch
51
+ drop_commands_cache
41
52
  cur_branch = current_branch_name
42
53
  if has_uncommited_changes
43
54
  puts red_color("Failed to release #{cur_branch}: you have uncommited changes")
@@ -55,6 +66,26 @@ class GitDj
55
66
  end
56
67
  end
57
68
 
69
+ def continue_prev_commands
70
+ cmds = File.read(LOG_FILE_NAME).chomp.strip.split("\n")
71
+ run_cmds(cmds)
72
+ end
73
+
74
+ def get_updates_from_origin
75
+ drop_commands_cache
76
+ cur_branch = current_branch_name
77
+ run_cmds [ "git pull origin #{cur_branch}" ]
78
+ end
79
+
80
+ def push_updates_to_origin
81
+ drop_commands_cache
82
+ cur_branch = current_branch_name
83
+ run_cmds [
84
+ "git pull origin #{cur_branch}",
85
+ "git push origin #{cur_branch}"
86
+ ]
87
+ end
88
+
58
89
  def current_branch_name
59
90
  out = %x[git branch]
60
91
  branch_string = out.split("\n").detect do |str|
@@ -72,18 +103,44 @@ class GitDj
72
103
  Usage:
73
104
  #{green_color('gdj integrate')} - merge current branch in staging branch, and switch back
74
105
  #{green_color('gdj release')} - merge current branch into master, and switch back
106
+ #{green_color('gdj get')} - pull changes from origin to local
107
+ #{green_color('gdj put')} - pull, then push changes from origin to local
108
+ #{green_color('gdj continue')} - continue previous failed command (after merge, etc)
75
109
 
76
110
  }
77
111
  end
78
112
 
79
113
  private
114
+
115
+ def drop_commands_cache
116
+ if File.exists?(LOG_FILE_NAME)
117
+ FileUtils.rm(LOG_FILE_NAME)
118
+ end
119
+ end
120
+
80
121
  def has_uncommited_changes
81
122
  %x[git diff].chomp.strip != ''
82
123
  end
83
124
 
84
125
  def run_cmds(cmds)
126
+ to_do = cmds.dup
85
127
  cmds.each do |cmd|
86
- system(cmd)
128
+ if system(cmd)
129
+ to_do.delete(cmd)
130
+ dump_cmds_to_disk(to_do)
131
+ else
132
+ puts red_color("Command failed: #{cmd}.")
133
+ puts red_color("Fix it and run gdj continue")
134
+ raise CommandFailedError.new
135
+ end
136
+ end
137
+ end
138
+
139
+ def dump_cmds_to_disk(cmds)
140
+ if cmds.any?
141
+ File.open(LOG_FILE_NAME, 'w') {|f| f.write(cmds.join("\n")) }
142
+ else
143
+ drop_commands_cache
87
144
  end
88
145
  end
89
146
 
@@ -97,3 +154,4 @@ private
97
154
 
98
155
  end
99
156
 
157
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_dj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-09 00:00:00.000000000 Z
12
+ date: 2012-12-24 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A simple and lightweight alternative to git flow
15
15
  email: