oban 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/bin/oban +12 -1
  2. data/lib/oban/oban.rb +67 -18
  3. data/lib/oban/version.rb +1 -1
  4. metadata +4 -4
data/bin/oban CHANGED
@@ -4,4 +4,15 @@ require 'oban'
4
4
  require 'oban/colorify'
5
5
 
6
6
  oban = Oban.new
7
- oban.push
7
+
8
+ if ARGV[0].nil? then
9
+ oban.show_help
10
+ else
11
+ arg = ARGV[0]
12
+ case arg
13
+ when "--help" then oban.show_help
14
+ when "deploy" then oban.deploy
15
+ when "rollback" then oban.rollback
16
+ when "push" then oban.push
17
+ end
18
+ end
data/lib/oban/oban.rb CHANGED
@@ -8,8 +8,11 @@ class Oban
8
8
  attr_accessor :submods # TODO: should be a list eventually
9
9
 
10
10
  def initialize
11
-
12
11
  set_config
12
+ end
13
+
14
+ def real_init
15
+ check_for_clean
13
16
 
14
17
  # grab config for current repository (based on github)
15
18
  current = `git remote show origin | grep Fetch`
@@ -36,9 +39,59 @@ class Oban
36
39
 
37
40
  self.heroku_remote = remote
38
41
 
42
+ set_remotes
43
+
39
44
  set_submods
40
45
 
41
- puts colorBlue("using #{heroku_remote}")
46
+ end
47
+
48
+ # show help message
49
+ def show_help
50
+ puts colorBlue("oban v??")
51
+ puts colorBlue("homepage: http://github.com/feydr/oban")
52
+ puts colorBlue("clone: git@github.com:feydr/oban.git")
53
+ puts colorBlue("\r" + "-"*20)
54
+ puts colorBlue("\tCommands:")
55
+ puts colorBlue("\t--help\tthis listing")
56
+ puts colorBlue("\tdeploy\tdeploy the local repository")
57
+ puts colorBlue("\trollback\trollback the local repository")
58
+ exit
59
+ end
60
+
61
+ # check for any uncommitted changes and bail if found
62
+ def check_for_clean
63
+ # can't believe there's not a simple yes/no here..
64
+ out = `git status --porcelain`
65
+
66
+ unless out.empty? then
67
+ puts colorRed("you have uncommitted changes -- please commit and try again:\r\t#{out}")
68
+ exit
69
+ end
70
+
71
+ end
72
+
73
+ def set_remotes
74
+ # only add remotes if necessary
75
+ remotes = `git remote`
76
+
77
+ if remotes.match('heroku').nil? then
78
+ `git remote add heroku #{self.heroku_remote}`
79
+ end
80
+ end
81
+
82
+ # checkout deploy - 1 branch from github and push to heroku
83
+ def rollback
84
+ puts colorBlue('rolling back to commit blah')
85
+ end
86
+
87
+ # ensure that our submodule is reset
88
+ def reinit_submods
89
+ # add back in our submodules
90
+ `git submodule init`
91
+ `git submodule update`
92
+
93
+ # ensure we checkout master (cause it'll default to headless)
94
+ `git --git-dir=#{self.submods}/.git checkout master`
42
95
  end
43
96
 
44
97
  def set_config
@@ -70,12 +123,11 @@ class Oban
70
123
 
71
124
  if !submods.empty?
72
125
  self.submods = submods.split[1]
73
-
74
- puts colorBlue("found submodule: #{self.submods}")
75
126
  end
76
127
 
77
128
  end
78
129
 
130
+ # remove all mention of submodules but leave the data in
79
131
  def rm_submods
80
132
  # rm git modules
81
133
  `rm -rf .gitmodules`
@@ -86,19 +138,22 @@ class Oban
86
138
  `git rm --cached #{self.submods}`
87
139
  end
88
140
 
141
+ # add in submod data
89
142
  def add_submod_data
90
143
  `git add #{self.submods}`
91
144
  end
92
145
 
93
- def push
146
+ def deploy
147
+
148
+ real_init
149
+
94
150
  # switch to master before anything else
95
151
  `git checkout master`
96
152
 
97
153
  puts colorBlue('deploying')
98
154
 
99
- # make sure we have config/s3.yml
100
- # make sure we have config/mongo.yml
101
- # make sure we have config/database.yml
155
+ # might need to change the logic on this to do reset --hard and
156
+ # friends so we don't clobber the remote deploy branch
102
157
 
103
158
  # test to see if deploy exists.. wipe it if it does..
104
159
  branches = `git branch`
@@ -116,25 +171,19 @@ class Oban
116
171
  add_submod_data
117
172
  end
118
173
 
119
- # only add remotes if necessary
120
- remotes = `git remote`
174
+ `git commit -a -m "deploying"`
121
175
 
122
- if remotes.match('heroku').nil? then
123
- `git remote add heroku #{self.heroku_remote}`
124
- end
176
+ # push to deploy branch first
177
+ `git push origin +deploy`
125
178
 
126
- `git commit -a -m "deploying"`
127
179
  # btw --force should NEVER be used (except for this case) ;)
128
180
  `git push --force heroku HEAD:master`
129
181
 
130
182
  # add back in our submodules
131
183
  puts colorBlue('switching back to master')
132
184
  `git checkout master`
133
- `git submodule init`
134
- `git submodule update`
135
185
 
136
- # ensure we checkout master (cause it'll default to headless)
137
- `git --git-dir=#{self.submods}/.git checkout master`
186
+ reinit_submods
138
187
 
139
188
  end
140
189
 
data/lib/oban/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Oban
2
- VERSION = "0.1.4" unless defined?(::Oban::VERSION)
2
+ VERSION = "0.1.5" unless defined?(::Oban::VERSION)
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oban
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
9
+ - 5
10
+ version: 0.1.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ian Eyberg
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-08 00:00:00 -05:00
18
+ date: 2010-10-12 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency