gritano 0.1.7 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +13 -1
- data/TODO +4 -8
- data/VERSION +1 -1
- data/bin/gritano-check +37 -6
- data/features/command.feature +9 -5
- data/features/step_definitions/command_step.rb +5 -4
- data/gritano.gemspec +2 -2
- data/lib/gritano/command.rb +8 -2
- data/spec/command_spec.rb +32 -8
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= Gritano v0.
|
1
|
+
= Gritano v0.2.0
|
2
2
|
|
3
3
|
Gritano is the simplest way to configure a git server over ssh. You can create repositories and manage user access using this practical tool.
|
4
4
|
|
@@ -34,6 +34,18 @@ create bare repositories:
|
|
34
34
|
and control access:
|
35
35
|
|
36
36
|
$ gritano repo +read proj.git igorbonadio
|
37
|
+
|
38
|
+
== User Access
|
39
|
+
|
40
|
+
Gritano 0.2.0 introduced a new feature that enables users to execute some simple commands:
|
41
|
+
|
42
|
+
$ ssh git@host.com repos
|
43
|
+
|
44
|
+
$ ssh git@host.com keys
|
45
|
+
|
46
|
+
$ ssh git@host.com key add mykey < id_rsa.pub
|
47
|
+
|
48
|
+
$ ssh git@host.com key rm mykey
|
37
49
|
|
38
50
|
== Contributing to Gritano
|
39
51
|
|
data/TODO
CHANGED
@@ -1,10 +1,3 @@
|
|
1
|
-
v0.2.0
|
2
|
-
- acesso do usuário via ssh
|
3
|
-
ssh git@host.com repos
|
4
|
-
ssh git@host.com keys
|
5
|
-
ssh git@host.com +key keyname < key.pub
|
6
|
-
ssh git@host.com -key keyname
|
7
|
-
|
8
1
|
v0.3.0
|
9
2
|
- acesso administrativo via ssh
|
10
3
|
ssh git@host.com user add username
|
@@ -27,4 +20,7 @@ v0.4.0
|
|
27
20
|
ssh git@host.com repo +read reponame.git username
|
28
21
|
ssh git@host.com repo +write reponame.git username
|
29
22
|
ssh git@host.com repo -read reponame.git username
|
30
|
-
ssh git@host.com repo -write reponame.git username
|
23
|
+
ssh git@host.com repo -write reponame.git username
|
24
|
+
|
25
|
+
v1.0.0
|
26
|
+
- melhorar sistema de dependencias
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/bin/gritano-check
CHANGED
@@ -4,14 +4,45 @@ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
|
4
4
|
|
5
5
|
require 'gritano'
|
6
6
|
|
7
|
+
def help
|
8
|
+
puts "
|
9
|
+
ssh user@host command
|
10
|
+
|
11
|
+
Examples:
|
12
|
+
ssh git@host.com repos
|
13
|
+
ssh git@host.com keys
|
14
|
+
ssh git@host.com key add keyname < key.pub
|
15
|
+
ssh git@host.com key rm keyname
|
16
|
+
|
17
|
+
--
|
18
|
+
v#{File.open(File.join(File.dirname(__FILE__), '..', 'VERSION')).readlines.join}"
|
19
|
+
end
|
20
|
+
|
7
21
|
ActiveRecord::Base.establish_connection(YAML::load(File.open(File.join(Etc.getpwuid.dir, '.gritano', 'database.yml'))))
|
8
22
|
|
9
23
|
login = ARGV[0]
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
24
|
+
command = Gritano::Command.eval(ENV['SSH_ORIGINAL_COMMAND'])
|
25
|
+
begin
|
26
|
+
case command[:access]
|
27
|
+
when :read, :write then
|
28
|
+
user = Gritano::User.find_by_login(login)
|
29
|
+
repository = Gritano::Repository.find_by_name(command[:repo])
|
30
|
+
if user and repository
|
31
|
+
if user.check_access(repository, command[:access])
|
32
|
+
exec "#{command[:command]} #{File.join(repository.full_path)}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
when :user_cmd
|
36
|
+
cmd = command[:command]
|
37
|
+
if cmd.start_with? "+key" or cmd.start_with? "-key"
|
38
|
+
tmp = cmd.split(" ")
|
39
|
+
tmp = tmp[0..-2] + [login] + tmp[-1..-1]
|
40
|
+
cmd = tmp.join(" ")
|
41
|
+
else
|
42
|
+
cmd = cmd + " " + login
|
43
|
+
end
|
44
|
+
exec "gritano user #{cmd}"
|
16
45
|
end
|
46
|
+
rescue
|
47
|
+
puts help
|
17
48
|
end
|
data/features/command.feature
CHANGED
@@ -4,9 +4,13 @@ Feature: Command
|
|
4
4
|
I want to know if a command is a read/write command
|
5
5
|
|
6
6
|
Scenario Outline: Write command
|
7
|
-
When I receive a "<
|
8
|
-
Then I should see that it is a "<access>"
|
7
|
+
When I receive a "<original_command>" command
|
8
|
+
Then I should see that it is a "<access>": "<command>" "<repo>"
|
9
9
|
Examples:
|
10
|
-
|
|
11
|
-
| git-receive-pack proj.git | write
|
12
|
-
| git-upload-pack proj.git | read
|
10
|
+
| original_command | access | command | repo |
|
11
|
+
| git-receive-pack proj.git | write | git-receive-pack | proj.git |
|
12
|
+
| git-upload-pack proj.git | read | git-upload-pack | proj.git |
|
13
|
+
| repos | user_cmd | repos | |
|
14
|
+
| keys | user_cmd | keys | |
|
15
|
+
| key add keyname | user_cmd | +key keyname | |
|
16
|
+
| key rm keyname | user_cmd | -key keyname | |
|
@@ -1,8 +1,9 @@
|
|
1
1
|
When /^I receive a "(.*?)" command$/ do |cmd|
|
2
|
-
@
|
2
|
+
@command = Gritano::Command.eval(cmd)
|
3
3
|
end
|
4
4
|
|
5
|
-
Then /^I should see that it is a "(.*?)"
|
6
|
-
@access.to_s.should be == access
|
7
|
-
@
|
5
|
+
Then /^I should see that it is a "(.*?)": "(.*?)" "(.*?)"$/ do |access, command, repo|
|
6
|
+
@command[:access].to_s.should be == access
|
7
|
+
@command[:command].to_s.should be == command
|
8
|
+
@command[:repo].to_s.should be == repo if repo
|
8
9
|
end
|
data/gritano.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "gritano"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Igor Bonadio"]
|
12
|
-
s.date = "2012-11-
|
12
|
+
s.date = "2012-11-07"
|
13
13
|
s.description = "Gritano is the simplest way to configure your git server over ssh. You can create repositories and manage user access."
|
14
14
|
s.email = "igorbonadio@gmail.com"
|
15
15
|
s.executables = ["gritano", "gritano-check"]
|
data/lib/gritano/command.rb
CHANGED
@@ -3,9 +3,15 @@ module Gritano
|
|
3
3
|
def self.eval(cmd)
|
4
4
|
case cmd
|
5
5
|
when /^git-receive-pack/ then
|
6
|
-
return :write, "git-receive-pack", self.repo(cmd)
|
6
|
+
return {access: :write, command: "git-receive-pack", repo: self.repo(cmd)}
|
7
7
|
when /^git-upload-pack/ then
|
8
|
-
return :read, "git-upload-pack", self.repo(cmd)
|
8
|
+
return {access: :read, command: "git-upload-pack", repo: self.repo(cmd)}
|
9
|
+
when /^repos/, /^keys/ then
|
10
|
+
return {access: :user_cmd, command: cmd}
|
11
|
+
when /^key add/ then
|
12
|
+
return {access: :user_cmd, command: '+' + cmd.sub(' add', '')}
|
13
|
+
when /^key rm/ then
|
14
|
+
return {access: :user_cmd, command: '-' + cmd.sub(' rm', '')}
|
9
15
|
end
|
10
16
|
end
|
11
17
|
|
data/spec/command_spec.rb
CHANGED
@@ -2,16 +2,40 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
2
|
|
3
3
|
describe Gritano::Command do
|
4
4
|
it 'should interpret git-receive-pack' do
|
5
|
-
|
6
|
-
access.to_s.should be == "write"
|
7
|
-
|
8
|
-
repo.to_s.should be == "teste.git"
|
5
|
+
command = Gritano::Command.eval("git-receive-pack 'teste.git'")
|
6
|
+
command[:access].to_s.should be == "write"
|
7
|
+
command[:command].should be == "git-receive-pack"
|
8
|
+
command[:repo].to_s.should be == "teste.git"
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'should interpret git-upload-pack' do
|
12
|
-
|
13
|
-
access.to_s.should be == "read"
|
14
|
-
|
15
|
-
repo.to_s.should be == "teste.git"
|
12
|
+
command = Gritano::Command.eval("git-upload-pack 'teste.git'")
|
13
|
+
command[:access].to_s.should be == "read"
|
14
|
+
command[:command].should be == "git-upload-pack"
|
15
|
+
command[:repo].to_s.should be == "teste.git"
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should interpret repos' do
|
19
|
+
command = Gritano::Command.eval("repos")
|
20
|
+
command[:access].to_s.should be == "user_cmd"
|
21
|
+
command[:command].should be == "repos"
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should interpret keys' do
|
25
|
+
command = Gritano::Command.eval("keys")
|
26
|
+
command[:access].to_s.should be == "user_cmd"
|
27
|
+
command[:command].should be == "keys"
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should interpret key add keyname' do
|
31
|
+
command = Gritano::Command.eval("key add keyname")
|
32
|
+
command[:access].to_s.should be == "user_cmd"
|
33
|
+
command[:command].should be == "+key keyname"
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should interpret -key keyname' do
|
37
|
+
command = Gritano::Command.eval("key rm keyname")
|
38
|
+
command[:access].to_s.should be == "user_cmd"
|
39
|
+
command[:command].should be == "-key keyname"
|
16
40
|
end
|
17
41
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gritano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
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-11-
|
12
|
+
date: 2012-11-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -245,7 +245,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
245
245
|
version: '0'
|
246
246
|
segments:
|
247
247
|
- 0
|
248
|
-
hash: -
|
248
|
+
hash: -1582708146400304202
|
249
249
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
250
250
|
none: false
|
251
251
|
requirements:
|