hubbard 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/hubbard +8 -2
- data/commands/list-permissions.rb +9 -5
- data/hubbard.gemspec +3 -3
- data/spec/hubbard_spec.rb +19 -0
- data/spec/spec_helper.rb +10 -6
- metadata +2 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.11
|
data/bin/hubbard
CHANGED
@@ -111,12 +111,13 @@ end
|
|
111
111
|
|
112
112
|
def is_authorized(project_name, action)
|
113
113
|
project_dir = find_project_dir(project_name)
|
114
|
-
return false
|
114
|
+
return false unless File.exist?(project_dir)
|
115
115
|
return true if @username == 'admin'
|
116
116
|
Dir.chdir(project_dir) do
|
117
117
|
if action == 'read' && File.read('.visibility').strip == 'public'
|
118
118
|
return true
|
119
119
|
end
|
120
|
+
return false unless File.exist?(".permissions")
|
120
121
|
File.read(".permissions").split("\n").each do |line|
|
121
122
|
permission = line.strip.split('=')
|
122
123
|
line_username = permission[0]
|
@@ -176,7 +177,12 @@ end
|
|
176
177
|
command_file = File.expand_path(File.join(File.dirname(__FILE__), "..", "commands", "#{command}.rb"))
|
177
178
|
|
178
179
|
if File.exist?(command_file)
|
179
|
-
|
180
|
+
begin
|
181
|
+
load command_file
|
182
|
+
rescue SystemCallError => e
|
183
|
+
$stderr.puts "SystemCallError [#{e.errno}]: #{e.message}"
|
184
|
+
exit e.errno
|
185
|
+
end
|
180
186
|
else
|
181
187
|
$stderr.puts "Unknown command: #{command}"
|
182
188
|
exit 1
|
@@ -2,9 +2,13 @@ project_name = read_project_name
|
|
2
2
|
authorize(project_name, 'admin')
|
3
3
|
dir = find_project_dir(project_name)
|
4
4
|
username = ARGV.shift
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
|
6
|
+
permissions_file = File.join(dir, ".permissions")
|
7
|
+
if File.exists?(permissions_file)
|
8
|
+
File.open(permissions_file, "r+") do |f|
|
9
|
+
f.flock(File::LOCK_EX)
|
10
|
+
contents = f.read
|
11
|
+
puts contents
|
12
|
+
f.flock(File::LOCK_UN)
|
13
|
+
end
|
10
14
|
end
|
data/hubbard.gemspec
CHANGED
@@ -5,14 +5,14 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{hubbard}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.11"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Matthew Foemmel"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-02-06}
|
13
13
|
s.description = %q{Hubbard is a command line tool for managing git repositories.}
|
14
14
|
s.email = %q{git@foemmel.com}
|
15
|
-
s.executables = ["hubbard", "hubbard
|
15
|
+
s.executables = ["hubbard", "hubbard"]
|
16
16
|
s.extra_rdoc_files = [
|
17
17
|
"LICENSE",
|
18
18
|
"README.md"
|
data/spec/hubbard_spec.rb
CHANGED
@@ -10,6 +10,10 @@ describe "Hubble" do
|
|
10
10
|
reset_file_system
|
11
11
|
end
|
12
12
|
|
13
|
+
it "should pass exitstatus along from SystemCallError" do
|
14
|
+
pending "Not sure how to make sure that hubbard is passing back the proper exit codes from SystemCallErrors. Doing so would introduce complexity or add something that shouldn't be callable."
|
15
|
+
end
|
16
|
+
|
13
17
|
it "should create project" do
|
14
18
|
hub("kipper", "create-project foo foo-desc")
|
15
19
|
projects = list_projects('kipper')
|
@@ -80,6 +84,21 @@ describe "Hubble" do
|
|
80
84
|
url.should == "#{ENV['USER']}@#{HUB_HOST}:foo/bar.git"
|
81
85
|
end
|
82
86
|
|
87
|
+
describe "when admin creates a project" do
|
88
|
+
before(:each) do
|
89
|
+
hub("admin", "create-project foo foo-desc")
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should not raise error on missing permissions file for non-admin listing permissions" do
|
93
|
+
lambda { hub("kipper", "list-permissions foo") }.should_not raise_error(Errno::ENOENT)
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should list project permissions for admin" do
|
97
|
+
permissions = hub("admin", "list-permissions foo")
|
98
|
+
permissions.should == ""
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
83
102
|
def with_test_project
|
84
103
|
Dir.mkdir('tmp')
|
85
104
|
Dir.chdir('tmp') do
|
data/spec/spec_helper.rb
CHANGED
@@ -26,18 +26,14 @@ def hub(username, command, input=nil)
|
|
26
26
|
else
|
27
27
|
result = `#{HUB} #{username} #{command}`
|
28
28
|
end
|
29
|
-
|
30
|
-
raise "Command failed: hub #{username} #{command}\n#{result}"
|
31
|
-
end
|
29
|
+
handle_exitstatus(command, result)
|
32
30
|
result
|
33
31
|
end
|
34
32
|
|
35
33
|
def git(username, command)
|
36
34
|
ENV['HUB_USERNAME'] = username
|
37
35
|
result = `git #{command}`
|
38
|
-
|
39
|
-
raise "Command failed: git #{command}:\n#{result}"
|
40
|
-
end
|
36
|
+
handle_exitstatus(command, result)
|
41
37
|
result
|
42
38
|
end
|
43
39
|
|
@@ -50,3 +46,11 @@ def list_projects(user)
|
|
50
46
|
hub(user, "list-projects").split("\n").map { |line| line.split[0] }
|
51
47
|
end
|
52
48
|
|
49
|
+
private
|
50
|
+
def handle_exitstatus(command, result)
|
51
|
+
exit_code = $?.exitstatus
|
52
|
+
if exit_code != 0
|
53
|
+
msg = "Command failed [#{exit_code}]: git #{command}:\n#{result}"
|
54
|
+
raise SystemCallError.new(msg, exit_code)
|
55
|
+
end
|
56
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hubbard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Foemmel
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-02-06 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -26,7 +26,6 @@ description: Hubbard is a command line tool for managing git repositories.
|
|
26
26
|
email: git@foemmel.com
|
27
27
|
executables:
|
28
28
|
- hubbard
|
29
|
-
- hubbard~
|
30
29
|
- hubbard
|
31
30
|
extensions: []
|
32
31
|
|