utsup 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sup.rb +27 -18
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
data/lib/sup.rb
CHANGED
@@ -6,11 +6,11 @@ require 'yaml'
|
|
6
6
|
require 'git'
|
7
7
|
|
8
8
|
module Sup
|
9
|
-
VERSION = '0.0.
|
9
|
+
VERSION = '0.0.6'
|
10
10
|
GIT_HOOKS = %w(post-commit post-receive post-merge post-checkout) #TODO: post-rebase?
|
11
11
|
|
12
12
|
GLOBAL_CONFIG_PATH = '~/.utsup'
|
13
|
-
PROJECT_CONFIG_PATH = '.utsup'
|
13
|
+
PROJECT_CONFIG_PATH = '.git/utsup.yml'
|
14
14
|
|
15
15
|
HELP_TEXT = <<-eos
|
16
16
|
=======================================
|
@@ -73,14 +73,14 @@ eos
|
|
73
73
|
def init(project_title)
|
74
74
|
|
75
75
|
# --- project init
|
76
|
-
|
76
|
+
project_title = File.basename(Dir.pwd) if project_title.blank? || project_title == "."
|
77
|
+
project = Api::Project.create :title => project_title
|
77
78
|
|
78
79
|
project_config_path = File.join(Dir.pwd, PROJECT_CONFIG_PATH)
|
79
80
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
end
|
81
|
+
project_config = YAML.load_file(project_config_path)
|
82
|
+
project_config["project_id"] = project.id
|
83
|
+
File.open(project_config_path,'w'){|f| YAML.dump( project_config, f )}
|
84
84
|
|
85
85
|
# --- write git hooks
|
86
86
|
GIT_HOOKS.each do |hook|
|
@@ -132,9 +132,13 @@ eos
|
|
132
132
|
# Git Update
|
133
133
|
# ===========================
|
134
134
|
|
135
|
+
def current_branch_name
|
136
|
+
`git branch 2> /dev/null | grep -e ^*`[/^\* (.*?)\n/,1]
|
137
|
+
end
|
138
|
+
|
135
139
|
def git_update(*args)
|
136
140
|
git = Git.open(Dir.pwd)
|
137
|
-
|
141
|
+
|
138
142
|
args.flatten!
|
139
143
|
|
140
144
|
case args.first.strip
|
@@ -147,23 +151,20 @@ eos
|
|
147
151
|
# TODO: get previous branch name from ref
|
148
152
|
|
149
153
|
Api::Status.add :status_type => "StatusCheckout",
|
150
|
-
:message =>
|
154
|
+
:message => current_branch_name
|
151
155
|
|
152
156
|
when "push":
|
153
157
|
resp = `git push #{args[1..-1]*' '} 2>&1`
|
154
158
|
puts resp
|
155
159
|
unless resp =~ /Everything up-to-date/
|
156
|
-
Api::Status.add :status_type => "StatusPush",
|
157
|
-
:message => git.branch.name
|
160
|
+
Api::Status.add :status_type => "StatusPush", :message => "pushed"
|
158
161
|
end
|
159
162
|
|
160
163
|
when "receive":
|
161
|
-
Api::Status.add :status_type => "StatusReceive"
|
162
|
-
:message => git.branch.name
|
164
|
+
Api::Status.add :status_type => "StatusReceive",:message => "received"
|
163
165
|
|
164
166
|
when "merge":
|
165
|
-
Api::Status.add :status_type => "StatusMerge",
|
166
|
-
:message => git.branch.name
|
167
|
+
Api::Status.add :status_type => "StatusMerge", :message => "merged"
|
167
168
|
|
168
169
|
when "commit":
|
169
170
|
|
@@ -173,7 +174,7 @@ eos
|
|
173
174
|
Api::Status.add :status_type => "StatusCommit",
|
174
175
|
:message => commit.message,
|
175
176
|
:ref => sha, :text => commit.diff_parent
|
176
|
-
|
177
|
+
|
177
178
|
else
|
178
179
|
puts "WTF git status is that?"
|
179
180
|
end
|
@@ -203,7 +204,7 @@ eos
|
|
203
204
|
puts "----------------------------------------------------------------------------------"
|
204
205
|
puts "This is UtSup#{" with #{name}" if name}:\n"
|
205
206
|
statuses.each do |status|
|
206
|
-
puts "=> #{status.to_command_line}"
|
207
|
+
puts "=> #{status.to_command_line.escape}"
|
207
208
|
end
|
208
209
|
puts "----------------------------------------------------------------------------------"
|
209
210
|
end
|
@@ -236,7 +237,10 @@ eos
|
|
236
237
|
return
|
237
238
|
end
|
238
239
|
|
239
|
-
create attributes.merge({:project_id => @@project_id})
|
240
|
+
create attributes.merge({:project_id => @@project_id, :branch => Sup::current_branch_name})
|
241
|
+
|
242
|
+
rescue ActiveResource::ResourceNotFound
|
243
|
+
puts "Your project_id was invalid, check #{PROJECT_CONFIG_PATH}"
|
240
244
|
end
|
241
245
|
end
|
242
246
|
|
@@ -335,3 +339,8 @@ eos
|
|
335
339
|
end
|
336
340
|
|
337
341
|
|
342
|
+
class String
|
343
|
+
def escape
|
344
|
+
eval '"'+ gsub(/\"/,'\"') + '"'
|
345
|
+
end
|
346
|
+
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utsup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Merwin
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
DrswbWvrKlA=
|
31
31
|
-----END CERTIFICATE-----
|
32
32
|
|
33
|
-
date: 2009-
|
33
|
+
date: 2009-10-01 00:00:00 -07:00
|
34
34
|
default_executable:
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
metadata.gz.sig
CHANGED
Binary file
|