ginst 0.1.3 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/Manifest +34 -8
- data/Rakefile +6 -3
- data/bin/ginst +11 -4
- data/features/browsing_project.feature +20 -0
- data/features/manage_projects.feature +36 -0
- data/features/manage_server.feature +17 -0
- data/features/step_definitions/manage_projects_steps.rb +35 -0
- data/features/step_definitions/manage_server_steps.rb +33 -0
- data/features/step_definitions/webrat_steps.rb +99 -0
- data/features/support/env.rb +29 -0
- data/features/support/git.rb +22 -0
- data/features/support/paths.rb +16 -0
- data/ginst.gemspec +8 -11
- data/lib/app/authorization.rb +1 -1
- data/lib/app/views/_commit.haml +8 -0
- data/lib/app/views/commit.haml +38 -8
- data/lib/app/views/commits.haml +1 -1
- data/lib/app/views/edit.haml +11 -0
- data/lib/app/views/layout.haml +10 -7
- data/lib/app/views/new.haml +19 -0
- data/lib/app/views/project.haml +4 -1
- data/lib/app/views/ref.haml +3 -0
- data/lib/app/views/style.sass +0 -1
- data/lib/app/webserver.rb +66 -76
- data/lib/ginst.rb +7 -5
- data/lib/ginst/core_extensions.rb +32 -0
- data/lib/ginst/ginst.rb +5 -72
- data/lib/ginst/project.rb +13 -38
- data/lib/ginst/project/base.rb +59 -0
- data/lib/ginst/project/build.rb +117 -0
- data/lib/ginst/project/commit_db.rb +29 -0
- data/lib/ginst/project/finders.rb +17 -0
- data/lib/ginst/project/grit.rb +53 -0
- data/lib/ginst/project/validations.rb +60 -0
- data/lib/ginst/test.rb +8 -0
- data/lib/ginst/test/base.rb +17 -0
- data/lib/ginst/test/dir.rb +39 -0
- data/lib/ginst/test/repo.rb +13 -0
- data/lib/ginst/test/run.rb +11 -0
- data/lib/ginst/web_server.rb +43 -0
- data/spec/fixtures/sample_repo.zip +0 -0
- data/spec/models/project_base_spec.rb +56 -0
- data/spec/models/project_build_spec.rb +18 -0
- data/spec/models/project_commit_db_spec.rb +19 -0
- data/spec/models/project_finders_spec.rb +34 -0
- data/spec/models/project_grit_spec.rb +19 -0
- data/spec/models/project_validations_spec.rb +72 -0
- data/spec/spec_helper.rb +8 -0
- metadata +56 -29
- metadata.gz.sig +0 -0
- data/lib/app/views/full_commit.haml +0 -38
- data/lib/app/views/project_index.haml +0 -11
- data/lib/ginst/command_line.rb +0 -47
- data/lib/ginst/master_command_line.rb +0 -40
- data/lib/ginst/plugin.rb +0 -16
- data/lib/ginst/server.rb +0 -51
- data/lib/ginst/templates/rgithook.rb +0 -6
data/lib/app/authorization.rb
CHANGED
@@ -5,7 +5,7 @@ module GINST
|
|
5
5
|
@auth ||= Rack::Auth::Basic::Request.new(request.env)
|
6
6
|
end
|
7
7
|
|
8
|
-
def unauthorized!(realm="
|
8
|
+
def unauthorized!(realm="Ginst Auth")
|
9
9
|
header 'WWW-Authenticate' => %(Basic realm="#{realm}")
|
10
10
|
throw :halt, [ 401, 'Authorization Required' ]
|
11
11
|
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
%li.commit{:class => commit.status }
|
2
|
+
%img{ :src => "http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(commit.author.email)}.jpg?s=42", :widht => 42, :height => 42}
|
3
|
+
.sha1
|
4
|
+
%a{ :href => "/projects/#{@project.name.slug}/commits/#{commit.id_abbrev}"}= commit.id_abbrev
|
5
|
+
.message= commit.short_message
|
6
|
+
.author
|
7
|
+
%a{ :href => "mailto:#{commit.author.email}"}= commit.author.name
|
8
|
+
.time= commit.date
|
data/lib/app/views/commit.haml
CHANGED
@@ -1,8 +1,38 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
%
|
5
|
-
|
6
|
-
|
7
|
-
%
|
8
|
-
|
1
|
+
= haml :_commit, :layout => false, :locals => {:commit => @commit}
|
2
|
+
- unless nil
|
3
|
+
%form{:method => 'post'}
|
4
|
+
%input{:type =>'submit', :value => 'Test this commit'}
|
5
|
+
- else
|
6
|
+
%form{:method => 'post'}
|
7
|
+
%input{:type =>'submit', :value => 'Tests are runing now', :disabled => 'disabled'}
|
8
|
+
|
9
|
+
%p.separator
|
10
|
+
Commit Info
|
11
|
+
%p.message
|
12
|
+
= @commit.message
|
13
|
+
%p.separator
|
14
|
+
Files
|
15
|
+
%p.files
|
16
|
+
%ul
|
17
|
+
-@commit.diffs.each do |diff|
|
18
|
+
- op = diff.deleted_file ? 'deleted' : (diff.new_file ? 'new' : (diff.a_path == diff.b_path ? 'update' : 'moved'))
|
19
|
+
%li{ :class => op }
|
20
|
+
= "(#{(diff.a_path == diff.b_path) ? 'igual' : 'cambio'})"
|
21
|
+
= diff.a_path || diff.b_path
|
22
|
+
- @commit.build.each do |k,v|
|
23
|
+
%p.separator=k.inspect
|
24
|
+
%p.message=v.inspect
|
25
|
+
|
26
|
+
%p.separator
|
27
|
+
Specs
|
28
|
+
%ul
|
29
|
+
%li
|
30
|
+
%dt Author:
|
31
|
+
%dd= @commit.author.name
|
32
|
+
%dt Commiter:
|
33
|
+
%dd= @commit.committer.name
|
34
|
+
%dt Commit Date:
|
35
|
+
%dd= @commit.date
|
36
|
+
%dt Work Date
|
37
|
+
%dd= @commit.authored_date
|
38
|
+
%dt
|
data/lib/app/views/commits.haml
CHANGED
@@ -5,4 +5,4 @@
|
|
5
5
|
- last_commit_date = commit.date.to_i / (60*60*24)
|
6
6
|
%li.separator
|
7
7
|
= (commit.date.year == Time.now.year) ? commit.date.strftime('%A %b %d') : commit.date.strftime('%A %b %d %Y')
|
8
|
-
= haml :
|
8
|
+
= haml :_commit, :layout => false, :locals => {:commit => commit}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
%h1 New Project
|
2
|
+
|
3
|
+
%form{:method => "post", :action => "/projects/#{@project.name.slug}"}
|
4
|
+
%input{:type => 'hidden', :name => '_method', :value => 'put'}
|
5
|
+
%fieldset
|
6
|
+
%label{:for => "build_process"}Build Process
|
7
|
+
%textarea{:name => "project[build_process]", :id => "build_process", :rows => 20, :cols => 80 }= @project.build_process
|
8
|
+
.error= @project.errors["build_process"]
|
9
|
+
|
10
|
+
%input{:type => "submit", :value => "Update"}
|
11
|
+
|
data/lib/app/views/layout.haml
CHANGED
@@ -19,14 +19,17 @@
|
|
19
19
|
%h2 Git Integration System
|
20
20
|
#left
|
21
21
|
%ul
|
22
|
-
-
|
22
|
+
- Ginst::Project.projects.each do |project|
|
23
23
|
%li
|
24
|
-
%a{:href => "/#{project.name}"}= project.name
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
%a{:href => "/projects/#{project.name.slug}"}= project.name
|
25
|
+
- if @project == project
|
26
|
+
%ul
|
27
|
+
- project.refs.each do |r|
|
28
|
+
%li
|
29
|
+
%a{:href => "/projects/#{project.name.slug}/refs/#{CGI::escape(r.name)}"}= r.name
|
30
|
+
%li
|
31
|
+
%a{:href=> "/projects/new"}New Project
|
29
32
|
#mainContent
|
30
33
|
=yield
|
31
34
|
#footer
|
32
|
-
%p
|
35
|
+
%p== Ginst <span class='version'>(Ginst::VERSION)</span> -- Powered by RGitHook <span class='version'>(RGitHook::VERSION)</span>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
%h1 New Project
|
2
|
+
|
3
|
+
%form{:method => "post", :action => "/projects"}
|
4
|
+
%fieldset
|
5
|
+
%legend Project data
|
6
|
+
%label{:for => "project_name"}Name
|
7
|
+
%input{:type => "text", :name => "project[name]", :id => "project_name", :value => @project.name}
|
8
|
+
.error= @project.errors["name"]
|
9
|
+
%br/
|
10
|
+
%label{:for => "project_dir"}Local directory
|
11
|
+
%input{:type => "text", :name => "project[dir]", :id => "project_dir", :value => @project.dir}
|
12
|
+
.error= @project.errors["dir"]
|
13
|
+
|
14
|
+
%label{:for => "build_process"}Build Process
|
15
|
+
%textarea{:name => "project[build_process]", :id => "build_process" , :rows => 20, :cols => 80}= @project.build_process
|
16
|
+
.error= @project.errors["build_process"]
|
17
|
+
|
18
|
+
%input{:type => "submit", :value => "Create"}
|
19
|
+
|
data/lib/app/views/project.haml
CHANGED
data/lib/app/views/style.sass
CHANGED
data/lib/app/webserver.rb
CHANGED
@@ -1,113 +1,103 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'rubygems'
|
3
3
|
require 'sinatra'
|
4
|
-
require '
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
require '
|
11
|
-
|
12
|
-
rescue LoadError
|
13
|
-
|
4
|
+
require File.dirname(__FILE__)+'/authorization'
|
5
|
+
|
6
|
+
|
7
|
+
unless defined?(Ginst)
|
8
|
+
begin
|
9
|
+
require File.dirname(__FILE__)+'/../ginst.rb'
|
10
|
+
require 'ruby-debug'
|
11
|
+
puts 'Using development ginst'
|
12
|
+
rescue LoadError
|
13
|
+
require 'ginst'
|
14
|
+
end
|
14
15
|
end
|
15
16
|
|
16
17
|
|
18
|
+
|
17
19
|
set :views, File.dirname(__FILE__) + '/views'
|
18
20
|
set :public, File.dirname(__FILE__) + '/views/assets'
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
text.gsub!("\t",' ')
|
23
|
-
text.gsub!("\n",'<br/>')
|
24
|
-
text
|
25
|
-
end
|
26
|
-
|
27
|
-
def redirect_back
|
28
|
-
redirect request.referer
|
29
|
-
end
|
22
|
+
get '/' do
|
23
|
+
haml :index
|
30
24
|
end
|
31
25
|
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
get '/style.css' do
|
27
|
+
content_type 'text/css', :charset => 'utf-8'
|
28
|
+
# css_files = Dir.glob(File.join(File.dirname(File.expand_path(__FILE__)),'views','assets','*.css'))
|
29
|
+
# css_files.map{|f| File.read f}.join("\n")
|
30
|
+
sass :style
|
35
31
|
end
|
36
32
|
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
post '/projects' do
|
34
|
+
@project = Ginst::Project.new(params[:project])
|
35
|
+
if @project.save
|
36
|
+
redirect "/projects/#{@project.name.slug}"
|
37
|
+
else
|
38
|
+
haml :new
|
39
|
+
end
|
40
40
|
end
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
@per_page = (params[:per_page] && params[:per_page].to_i) || 30
|
46
|
-
@page = (params[:page] && params[:page].to_i) || 0
|
47
|
-
@commits = @project.repo.commits(@branch.commit.id,@per_page, @page*@per_page)
|
42
|
+
get '/projects/new' do
|
43
|
+
@project = Ginst::Project.new
|
44
|
+
haml :new
|
48
45
|
end
|
49
46
|
|
50
|
-
|
51
|
-
|
52
|
-
|
47
|
+
get '/projects/:id' do
|
48
|
+
@project = Ginst::Project.find_by_slug(params[:id]) or raise Sinatra::NotFound
|
49
|
+
haml :project
|
53
50
|
end
|
54
51
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
52
|
+
put '/projects/:id' do
|
53
|
+
@project = Ginst::Project.find_by_slug(params[:id]) or raise Sinatra::NotFound
|
54
|
+
@project.build_process = params[:project][:build_process]
|
55
|
+
|
56
|
+
if @project.save
|
57
|
+
redirect request.env["REQUEST_URI"] || request.env["PATH_INFO"]
|
58
|
+
else
|
59
|
+
redirect "/projects/#{@project.name.slug}/edit"
|
60
|
+
end
|
61
61
|
end
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
delete '/projects/:id' do
|
64
|
+
@project = Ginst::Project.find_by_slug(params[:id]) or raise Sinatra::NotFound
|
65
|
+
@project.destroy
|
66
|
+
|
67
|
+
redirect request.env["REQUEST_URI"] || request.env["PATH_INFO"]
|
66
68
|
end
|
67
69
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
redirect_back
|
70
|
+
get '/projects/:project/edit' do
|
71
|
+
@project = Ginst::Project.find_by_slug(params[:project]) or raise Sinatra::NotFound
|
72
|
+
haml :edit
|
72
73
|
end
|
73
74
|
|
74
|
-
get '/:project/
|
75
|
-
|
76
|
-
|
75
|
+
get '/projects/:project/refs/:refname' do
|
76
|
+
@project = Ginst::Project.find_by_slug(params[:project]) or raise Sinatra::NotFound
|
77
|
+
@ref = @project.find_ref(CGI::unescape(params[:refname])) or raise Sinatra::NotFound
|
78
|
+
@commits = @ref.commits
|
79
|
+
haml :ref
|
77
80
|
end
|
78
81
|
|
79
|
-
get '/:project/
|
80
|
-
|
81
|
-
|
82
|
+
get '/projects/:project/commits/:commit' do
|
83
|
+
@project = Ginst::Project.find_by_slug(params[:project]) or raise Sinatra::NotFound
|
84
|
+
@commit = @project.find_commit(params[:commit]) or raise Sinatra::NotFound
|
85
|
+
haml :commit
|
82
86
|
end
|
83
87
|
|
84
|
-
post '/:project/
|
85
|
-
|
86
|
-
@project.
|
87
|
-
|
88
|
+
post '/projects/:project/commits/:commit' do
|
89
|
+
@project = Ginst::Project.find_by_slug(params[:project]) or raise Sinatra::NotFound
|
90
|
+
@commit = @project.find_commit(params[:commit]) or raise Sinatra::NotFound
|
91
|
+
@commit.build!
|
92
|
+
redirect request.env["REQUEST_URI"]
|
88
93
|
end
|
89
94
|
|
95
|
+
|
90
96
|
not_found do
|
91
97
|
haml :not_found, :layout => :clean_layout
|
92
98
|
end
|
99
|
+
|
93
100
|
|
94
|
-
error do
|
95
|
-
'Sorry there was a nasty error - ' + env['sinatra.error'].name
|
96
|
-
end
|
97
|
-
|
98
|
-
error Exception do
|
99
|
-
'Sorry there was a nasty error - ' + env['sinatra.error'].name
|
100
|
-
end
|
101
101
|
|
102
|
-
get '/about' do
|
103
|
-
"I'm running on Version " + Sinatra::VERSION
|
104
|
-
end
|
105
102
|
|
106
|
-
|
107
|
-
content_type 'text/css', :charset => 'utf-8'
|
108
|
-
# css_files = Dir.glob(File.join(File.dirname(File.expand_path(__FILE__)),'views','assets','*.css'))
|
109
|
-
# css_files.map{|f| File.read f}.join("\n")
|
110
|
-
sass :style
|
111
|
-
end
|
112
|
-
|
113
|
-
|
103
|
+
|
data/lib/ginst.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
$:.unshift File.dirname(__FILE__)
|
2
2
|
|
3
3
|
module Ginst
|
4
|
-
VERSION = '0.
|
4
|
+
VERSION = '0.2.2'
|
5
5
|
end
|
6
6
|
|
7
7
|
require 'rubygems'
|
8
|
-
require '
|
8
|
+
require 'grit'
|
9
|
+
require 'ginst/core_extensions'
|
9
10
|
|
10
|
-
|
11
|
-
Ginst.autoload(:
|
12
|
-
Ginst.autoload(:
|
11
|
+
require 'ginst/ginst'
|
12
|
+
Ginst.autoload(:Project, 'ginst/project')
|
13
|
+
Ginst.autoload(:WebServer, 'ginst/web_server')
|
14
|
+
Ginst.autoload(:Test,'ginst/test')
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class String
|
2
|
+
def slug
|
3
|
+
str = self.dup
|
4
|
+
accents = {
|
5
|
+
['á','à','â','ä','ã'] => 'a',
|
6
|
+
['Ã','Ä','Â','À','�?'] => 'A',
|
7
|
+
['é','è','ê','ë'] => 'e',
|
8
|
+
['Ë','É','È','Ê'] => 'E',
|
9
|
+
['í','ì','î','ï'] => 'i',
|
10
|
+
['�?','Î','Ì','�?'] => 'I',
|
11
|
+
['ó','ò','ô','ö','õ'] => 'o',
|
12
|
+
['Õ','Ö','Ô','Ò','Ó'] => 'O',
|
13
|
+
['ú','ù','û','ü'] => 'u',
|
14
|
+
['Ú','Û','Ù','Ü'] => 'U',
|
15
|
+
['ç'] => 'c', ['Ç'] => 'C',
|
16
|
+
['ñ'] => 'n', ['Ñ'] => 'N'
|
17
|
+
}
|
18
|
+
accents.each do |ac,rep|
|
19
|
+
ac.each do |s|
|
20
|
+
str = str.gsub(s, rep)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
str = str.gsub(/[^a-zA-Z0-9 ]/,"")
|
24
|
+
|
25
|
+
str = str.gsub(/[ ]+/," ")
|
26
|
+
str = str.strip
|
27
|
+
str = str.gsub(/ /,"-")
|
28
|
+
|
29
|
+
str = str.downcase
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
data/lib/ginst/ginst.rb
CHANGED
@@ -1,73 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
module Ginst
|
6
|
-
class Ginst
|
7
|
-
|
8
|
-
attr_reader :projects
|
9
|
-
def initialize(path = nil)
|
10
|
-
@projects = [Project.new(path || Dir.pwd)]
|
11
|
-
end
|
12
|
-
|
13
|
-
def [](project_name)
|
14
|
-
@projects.select{|p| p.name == project_name}.first
|
15
|
-
end
|
16
|
-
|
17
|
-
def add_project(path_or_project)
|
18
|
-
case path_or_project
|
19
|
-
when String
|
20
|
-
@projects << Project.new(path_or_project)
|
21
|
-
when Project
|
22
|
-
@projects << path_or_project
|
23
|
-
end
|
24
|
-
end
|
25
|
-
# Install Ginst in the given path
|
26
|
-
# Options can be:
|
27
|
-
# * :verbose: true/false
|
28
|
-
def self.install(path,options={})
|
29
|
-
self.new(path).install(options)
|
30
|
-
end
|
31
|
-
|
32
|
-
def install(options = {})
|
33
|
-
opts={:verbose => true, :interactive => true}
|
34
|
-
opts.merge(options)
|
35
|
-
|
36
|
-
puts 'Installing rgithook' if opts[:verbose]
|
37
|
-
@rgithook = RGitHook::RGitHook.new(@path)
|
38
|
-
@rgithook.install(opts[:interactive])
|
39
|
-
|
40
|
-
#check for a valid repo
|
41
|
-
@path = Grit::Repo.new(@path).path
|
42
|
-
@ginst_dir = File.join(@path,'ginst')
|
43
|
-
|
44
|
-
puts 'Installing ginst' if opts[:verbose]
|
45
|
-
install_ginst(opts)
|
46
|
-
|
47
|
-
puts 'Installing hooks' if opts[:verbose]
|
48
|
-
install_hook(opts)
|
49
|
-
end
|
50
|
-
|
51
|
-
def self.install_master(path,options)
|
52
|
-
self.new(path).install_mater(options)
|
53
|
-
end
|
54
|
-
|
55
|
-
private
|
56
|
-
|
57
|
-
def install_ginst(opts)
|
58
|
-
puts "Installing Ginst in #{@path}" if opts[:verbose]
|
59
|
-
FileUtils.mkdir(@ginst_dir) unless File.directory? @ginst_dir
|
60
|
-
FileUtils.cp_r(template_path,@ginst_dir, {:preserve => true, :verbose => opts[:verbose]})
|
61
|
-
end
|
62
|
-
|
63
|
-
def install_hook(opts)
|
64
|
-
puts
|
65
|
-
@rgithook.conf_file
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
def template_path
|
70
|
-
File.join(File.dirname(__FILE__),'..','app','.')
|
71
|
-
end
|
1
|
+
module Ginst::Ginst
|
2
|
+
@working_dir = Dir.pwd
|
3
|
+
class << self
|
4
|
+
attr_accessor :working_dir
|
72
5
|
end
|
73
|
-
end
|
6
|
+
end
|