hubbard 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +11 -3
- data/VERSION +1 -1
- data/bin/hubbard +2 -0
- data/commands/create-repository.rb +2 -1
- data/commands/fork-repository.rb +15 -0
- data/commands/help.rb +4 -0
- data/commands/list-forks.rb +17 -0
- data/commands/list-permissions.rb +0 -5
- data/commands/list-repositories.rb +1 -1
- data/spec/hubbard_spec.rb +52 -0
- metadata +5 -2
data/README.md
CHANGED
@@ -5,12 +5,12 @@ Hubbard is a command line tool for managing shared git repositories in a team en
|
|
5
5
|
|
6
6
|
Hubbard uses public SSH keys to keep track of who is executing what commands. This means you only have to create a single account on the server, instead of one per user.
|
7
7
|
|
8
|
-
|
8
|
+
Hubbard was heavily inspired by gitosis, another tool for managing git repositories. However, the goal of Hubbard was to place less burden on the system administrator by allowing users to manage permissions for their own projects.
|
9
9
|
|
10
10
|
How It Works
|
11
11
|
============
|
12
12
|
|
13
|
-
All comminication between users
|
13
|
+
All comminication between users and the Hubbard server happens over SSH. Users must register their public SSH keys with the server before they can connect to it.
|
14
14
|
|
15
15
|
When a user connects to the Hubbard server, the SSH daemon tries to find the user's public SSH key the "~/.ssh/authorized_keys" file on the server. That file also contains information about which user to associate with that SSH key. That information is automatically passed to the "hubbard" executable, so there is no way for users to run other programs on the server.
|
16
16
|
|
@@ -27,6 +27,13 @@ Unless you installed the gem using "sudo", the "hubbard" executable will be foun
|
|
27
27
|
|
28
28
|
export PATH=$PATH:~/.gem/ruby/1.8/bin
|
29
29
|
|
30
|
+
Create the directories and files that SSH needs to work.
|
31
|
+
[in hub's home directory]
|
32
|
+
mkdir .ssh
|
33
|
+
chmod 700 .ssh
|
34
|
+
touch .ssh/authorized_keys
|
35
|
+
chmod 600 .ssh/authorized_keys
|
36
|
+
|
30
37
|
The next step is to create an SSH keypair to access the "admin" account on the Hubbard server. You should only use this key when performing tasks that require admin access. Run this on the machine that you'll be accessing Hubbard from (i.e. your local workstation, not the server):
|
31
38
|
|
32
39
|
$ ssh-keygen -f ~/.ssh/hubadmin
|
@@ -58,4 +65,5 @@ Assuming your SSH keys have been set up correcly, you can simply SSH into the se
|
|
58
65
|
|
59
66
|
To test it, run:
|
60
67
|
|
61
|
-
$ hub help
|
68
|
+
$ hub help
|
69
|
+
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/bin/hubbard
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'fileutils'
|
4
|
+
require 'socket'
|
4
5
|
|
5
6
|
PROJECT_REGEX='[a-zA-Z0-9\-]{1,32}'
|
6
7
|
REPOSITORY_REGEX='[a-zA-Z0-9\-]{1,32}'
|
7
8
|
USERNAME_REGEX='[a-zA-Z0-9\-]{1,32}'
|
8
9
|
|
9
10
|
HUB_DATA = ENV['HUB_DATA'] || File.expand_path("~/.hubbard")
|
11
|
+
HUB_HOST = ENV['HUB_HOST'] || Socket.gethostname
|
10
12
|
|
11
13
|
FileUtils.mkdir_p(File.join(HUB_DATA, "projects"))
|
12
14
|
FileUtils.mkdir_p(File.join(HUB_DATA, "accounts"))
|
@@ -4,5 +4,6 @@ authorize(project_name, 'admin')
|
|
4
4
|
dir = find_repository_dir(project_name, repository_name)
|
5
5
|
FileUtils.mkdir_p(dir)
|
6
6
|
Dir.chdir(dir) do
|
7
|
-
|
7
|
+
exit $? unless system "git init --bare"
|
8
|
+
exec "git config hubbard.forkid #{project_name}/#{repository_name}/#{Time.now.to_i}"
|
8
9
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
from_project_name = read_project_name
|
2
|
+
from_repository_name = read_repository_name
|
3
|
+
to_project_name = read_project_name
|
4
|
+
to_repository_name = read_repository_name
|
5
|
+
authorize(from_project_name, 'read')
|
6
|
+
authorize(to_project_name, 'admin')
|
7
|
+
from_dir = find_repository_dir(from_project_name, from_repository_name)
|
8
|
+
to_dir = find_repository_dir(to_project_name, to_repository_name)
|
9
|
+
forkid = Dir.chdir(from_dir) { `git config --get hubbard.forkid` }
|
10
|
+
FileUtils.mkdir_p(to_dir)
|
11
|
+
exit $? unless system "git clone --bare #{from_dir} #{to_dir}"
|
12
|
+
Dir.chdir(to_dir) do
|
13
|
+
exec "git config hubbard.forkid #{forkid}"
|
14
|
+
end
|
15
|
+
|
data/commands/help.rb
CHANGED
@@ -9,11 +9,15 @@ delete-project <project>
|
|
9
9
|
|
10
10
|
Repositories:
|
11
11
|
|
12
|
+
list-repositories <project>
|
12
13
|
create-repository <project> <repository>
|
13
14
|
delete-repository <project> <repository>
|
15
|
+
fork-repository <from-project> <from-repository> <to-project> <to-repository>
|
16
|
+
list-forks <project> <repository>
|
14
17
|
|
15
18
|
Permissions:
|
16
19
|
|
20
|
+
list-permissions <project>
|
17
21
|
add-permission <project> <username> read|write|admin
|
18
22
|
remove-permission <project> <username>
|
19
23
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
project_name = read_project_name
|
2
|
+
repository_name = read_repository_name
|
3
|
+
authorize(project_name, 'read')
|
4
|
+
forkid = Dir.chdir(find_repository_dir(project_name, repository_name)) { `git config --get hubbard.forkid` }
|
5
|
+
project_dir = find_project_dir(project_name)
|
6
|
+
Dir.foreach(File.join(HUB_DATA, 'projects')) do |dir|
|
7
|
+
next if dir == "." || dir == ".."
|
8
|
+
next unless is_authorized(dir, 'read')
|
9
|
+
Dir.foreach(find_project_dir(project_name)) do |repository_name|
|
10
|
+
next if repository_name =~ /^\./
|
11
|
+
Dir.chdir(find_repository_dir(project_name, repository_name)) do
|
12
|
+
if forkid == `git config --get hubbard.forkid`
|
13
|
+
puts "#{project_name}/#{repository_name}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -2,11 +2,6 @@ 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
|
-
action = ARGV.shift
|
6
|
-
unless ['admin','write','read'].member?(action)
|
7
|
-
$stderr.puts "Not a valid action (must be one of: read, write, admin)"
|
8
|
-
exit 1
|
9
|
-
end
|
10
5
|
File.open(File.join(dir, ".permissions"), "r+") do |f|
|
11
6
|
f.flock(File::LOCK_EX)
|
12
7
|
contents = f.read
|
@@ -2,6 +2,6 @@ project_name = read_project_name
|
|
2
2
|
authorize(project_name, 'read')
|
3
3
|
Dir.foreach(find_project_dir(project_name)) do |repository_name|
|
4
4
|
next if repository_name =~ /^\./
|
5
|
-
git_url = "#{ENV['USER']}@#{
|
5
|
+
git_url = "#{ENV['USER']}@#{HUB_HOST}:#{project_name}/#{repository_name}.git"
|
6
6
|
puts "#{repository_name}\t#{git_url}"
|
7
7
|
end
|
data/spec/hubbard_spec.rb
CHANGED
@@ -160,6 +160,58 @@ describe "Hubble" do
|
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
163
|
+
it "should fork repository in same project" do
|
164
|
+
hub("kipper", "create-project foo")
|
165
|
+
hub("kipper", "create-repository foo bar")
|
166
|
+
|
167
|
+
with_test_project do
|
168
|
+
git("kipper", "push #{ENV['USER']}@#{HUB_HOST}:foo/bar.git master")
|
169
|
+
hub("kipper", "fork-repository foo bar foo bar2")
|
170
|
+
git("kipper", "pull #{ENV['USER']}@#{HUB_HOST}:foo/bar2.git master")
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
it "should fork repository in different project" do
|
175
|
+
hub("kipper", "create-project foo")
|
176
|
+
hub("kipper", "create-project foo2")
|
177
|
+
hub("kipper", "create-repository foo bar")
|
178
|
+
|
179
|
+
with_test_project do
|
180
|
+
git("kipper", "push #{ENV['USER']}@#{HUB_HOST}:foo/bar.git master")
|
181
|
+
hub("kipper", "fork-repository foo bar foo2 bar2")
|
182
|
+
git("kipper", "pull #{ENV['USER']}@#{HUB_HOST}:foo2/bar2.git master")
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should track projects related by forking" do
|
187
|
+
hub("kipper", "create-project foo")
|
188
|
+
hub("kipper", "create-repository foo bar")
|
189
|
+
|
190
|
+
with_test_project do
|
191
|
+
git("kipper", "push #{ENV['USER']}@#{HUB_HOST}:foo/bar.git master")
|
192
|
+
hub("kipper", "fork-repository foo bar foo bar2")
|
193
|
+
hub("kipper", "list-forks foo bar").should == "foo/bar\nfoo/bar2\n"
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
it "should require read access to fork repository" do
|
198
|
+
hub("kipper", "create-project foo")
|
199
|
+
hub("kipper", "create-project foo2")
|
200
|
+
hub("kipper", "create-repository foo bar")
|
201
|
+
|
202
|
+
with_test_project do
|
203
|
+
git("kipper", "push #{ENV['USER']}@#{HUB_HOST}:foo/bar.git master")
|
204
|
+
lambda { hub("tiger", "fork-repository foo bar foo2 bar2") }.should raise_error
|
205
|
+
hub("kipper", "add-permission foo tiger read")
|
206
|
+
lambda { hub("tiger", "fork-repository foo bar foo2 bar2") }.should raise_error
|
207
|
+
hub("kipper", "add-permission foo2 tiger write")
|
208
|
+
lambda { hub("tiger", "fork-repository foo bar foo2 bar2") }.should raise_error
|
209
|
+
hub("kipper", "add-permission foo2 tiger admin")
|
210
|
+
hub("tiger", "fork-repository foo bar foo2 bar2")
|
211
|
+
hub("kipper", "add-permission foo2 tiger admin")
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
163
215
|
it "should remove permission" do
|
164
216
|
hub("kipper", "create-project foo")
|
165
217
|
hub("kipper", "create-repository foo bar")
|
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.6
|
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-01-
|
12
|
+
date: 2010-01-26 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -26,6 +26,7 @@ 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~
|
29
30
|
- hubbard
|
30
31
|
extensions: []
|
31
32
|
|
@@ -45,9 +46,11 @@ files:
|
|
45
46
|
- commands/create-project.rb
|
46
47
|
- commands/create-repository.rb
|
47
48
|
- commands/delete-project.rb
|
49
|
+
- commands/fork-repository.rb
|
48
50
|
- commands/git-receive-pack.rb
|
49
51
|
- commands/git-upload-pack.rb
|
50
52
|
- commands/help.rb
|
53
|
+
- commands/list-forks.rb
|
51
54
|
- commands/list-keys.rb
|
52
55
|
- commands/list-permissions.rb
|
53
56
|
- commands/list-projects.rb
|