From e47104bd7a08c57f6dc6e5e8b9b5f2a63c75f9eb Mon Sep 17 00:00:00 2001 From: gliptak Date: Wed, 9 Jan 2013 14:43:49 -0500 Subject: [PATCH 01/32] Use ruby 1.9.3-p327 on travis-ci --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e8bd744267f..6d39488df27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +language: ruby env: - DB=postgresql - DB=mysql @@ -8,7 +9,7 @@ branches: only: - 'master' rvm: - - 1.9.2 + - 1.9.3-p327 services: - mysql - postgresql From 4eac403e3b3a32188c48d006e431ee838cd5c3dc Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Wed, 9 Jan 2013 23:56:47 +0100 Subject: [PATCH 02/32] Fix sidekiq task to use Rails --- lib/tasks/sidekiq.rake | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/tasks/sidekiq.rake b/lib/tasks/sidekiq.rake index 6bbcb3da4bc..01da919d7f8 100644 --- a/lib/tasks/sidekiq.rake +++ b/lib/tasks/sidekiq.rake @@ -6,18 +6,10 @@ namespace :sidekiq do desc "GITLAB | Start sidekiq" task :start do - run "nohup bundle exec sidekiq -q post_receive,mailer,system_hook,common,default -e #{rails_env} -P #{pidfile} >> #{root_path}/log/sidekiq.log 2>&1 &" - end - - def root_path - @root_path ||= File.join(File.expand_path(File.dirname(__FILE__)), "../..") + run "nohup bundle exec sidekiq -q post_receive,mailer,system_hook,common,default -e #{Rails.env} -P #{pidfile} >> #{Rails.root.join("log", "sidekiq.log")} 2>&1 &" end def pidfile - "#{root_path}/tmp/pids/sidekiq.pid" - end - - def rails_env - ENV['RAILS_ENV'] || "production" + Rails.root.join("tmp", "pids", "sidekiq.pid") end end From 7cd03836e55f842fd518b4637c19235ee8701f17 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Thu, 10 Jan 2013 00:08:15 +0100 Subject: [PATCH 03/32] Fix sidekiq check task --- lib/tasks/gitlab/check.rake | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index 5d850a17fe3..665973e2303 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -2,7 +2,7 @@ namespace :gitlab do desc "GITLAB | Check the configuration of GitLab and its environment" task check: %w{gitlab:env:check gitlab:gitolite:check - gitlab:resque:check + gitlab:sidekiq:check gitlab:app:check} @@ -870,22 +870,22 @@ namespace :gitlab do - namespace :resque do + namespace :sidekiq do desc "GITLAB | Check the configuration of Sidekiq" task check: :environment do warn_user_is_not_gitlab - start_checking "Resque" + start_checking "Sidekiq" - check_resque_running + check_sidekiq_running - finished_checking "Resque" + finished_checking "Sidekiq" end # Checks ######################## - def check_resque_running + def check_sidekiq_running print "Running? ... " if run_and_match("ps aux | grep -i sidekiq", /sidekiq \d\.\d\.\d.+$/) @@ -893,9 +893,7 @@ namespace :gitlab do else puts "no".red try_fixing_it( - "sudo service gitlab restart", - "or", - "sudo /etc/init.d/gitlab restart" + "sudo -u gitlab -H bundle exec rake sidekiq:start" ) for_more_information( see_installation_guide_section("Install Init Script"), From 2b38c8a15682f7531d97eb9f4758821148741469 Mon Sep 17 00:00:00 2001 From: James Newton Date: Wed, 9 Jan 2013 22:17:03 -0600 Subject: [PATCH 04/32] remove passenger_fix.rb, which due to the recent removal of Resque in favor of sidekiq breaks gitlab in passenger --- config/initializers/passenger_fix.rb | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 config/initializers/passenger_fix.rb diff --git a/config/initializers/passenger_fix.rb b/config/initializers/passenger_fix.rb deleted file mode 100644 index 3a88eb10a36..00000000000 --- a/config/initializers/passenger_fix.rb +++ /dev/null @@ -1,16 +0,0 @@ -if defined?(PhusionPassenger) - - # When you're using Passenger with smart-lv2 (default) or smart spawn method, - # Resque doesn't recognize that it has been forked and should re-establish - # Redis connection. You can see this error message in log: - # Redis::InheritedError, Tried to use a connection from a child process - # without reconnecting. You need to reconnect to Redis after forking. - # - # This solution is based on - # https://github.com/redis/redis-rb/wiki/redis-rb-on-Phusion-Passenger - # - PhusionPassenger.on_event(:starting_worker_process) do |forked| - # if we're in smart spawning mode, reconnect to Redis - Resque.redis.client.reconnect if forked - end -end From c2982c9a3116f95036d74530f7c20c692cb983d7 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 10 Jan 2013 08:43:25 +0200 Subject: [PATCH 05/32] sidekiq.log in admin area. Improved admin dashboard --- app/assets/stylesheets/common.scss | 1 + app/views/admin/dashboard/index.html.haml | 44 ++++++++++++++++++++--- app/views/admin/logs/show.html.haml | 16 +++++++++ 3 files changed, 56 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index bcaa6a2f76e..b72c9e93d9e 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -371,6 +371,7 @@ li.note { font-size: 48px; padding: 20px; text-align: center; + font-weight: normal; } } } diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml index 2e572aaba79..9a5e7edea0f 100644 --- a/app/views/admin/dashboard/index.html.haml +++ b/app/views/admin/dashboard/index.html.haml @@ -25,17 +25,51 @@ = link_to 'New User', new_admin_user_path, class: "btn small" .row - .span6 - %h3 Latest projects + .span4 + %h4 Latest projects %hr - @projects.each do |project| %p = link_to project.name_with_namespace, [:admin, project] - .span6 - %h3 Latest users + %span.light.right + = time_ago_in_words project.created_at + ago + + .span4 + %h4 Latest users %hr - @users.each do |user| %p = link_to [:admin, user] do = user.name - %small= user.email + %span.light.right + = time_ago_in_words user.created_at + ago + + .span4 + %h4 Stats + %hr + %p + Issues + %span.light.right + = Issue.count + %p + Merge Requests + %span.light.right + = MergeRequest.count + %p + Notes + %span.light.right + = Note.count + %p + Snippets + %span.light.right + = Snippet.count + %p + SSH Keys + %span.light.right + = Key.count + %p + Milestones + %span.light.right + = Milestone.count diff --git a/app/views/admin/logs/show.html.haml b/app/views/admin/logs/show.html.haml index 25644d6321a..c8be2ffa43c 100644 --- a/app/views/admin/logs/show.html.haml +++ b/app/views/admin/logs/show.html.haml @@ -5,6 +5,8 @@ = link_to "application.log", "#application", 'data-toggle' => 'tab' %li = link_to "production.log", "#production", 'data-toggle' => 'tab' + %li + = link_to "sidekiq.log", "#sidekiq", 'data-toggle' => 'tab' %p.light To prevent perfomance issues admin logs output the last 2000 lines .tab-content @@ -50,3 +52,17 @@ - Gitlab::Logger.read_latest_for('production.log').each do |line| %li %p= line + .tab-pane#sidekiq + .file_holder#README + .file_title + %i.icon-file + sidekiq.log + .right + = link_to '#', class: 'log-bottom' do + %i.icon-arrow-down + Scroll down + .file_content.logs + %ol + - Gitlab::Logger.read_latest_for('sidekiq.log').each do |line| + %li + %p= line From abc2bdc3aa49c2651f83dd6c577d4e61fe21293f Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 10 Jan 2013 08:43:25 +0200 Subject: [PATCH 06/32] Remove unused images. More use of font-awesome icons --- Gemfile | 2 +- Gemfile.lock | 6 ++--- app/assets/images/diff_file_add.png | Bin 177 -> 0 bytes app/assets/images/diff_file_delete.png | Bin 295 -> 0 bytes app/assets/images/diff_file_info.png | Bin 749 -> 0 bytes app/assets/images/diff_file_notice.png | Bin 302 -> 0 bytes app/assets/images/event_filter_comments.png | Bin 750 -> 0 bytes app/assets/images/event_filter_merged.png | Bin 463 -> 0 bytes app/assets/images/event_filter_push.png | Bin 632 -> 0 bytes app/assets/images/event_filter_team.png | Bin 1337 -> 0 bytes app/assets/images/event_mr_merged.png | Bin 463 -> 0 bytes app/assets/images/event_push.png | Bin 632 -> 0 bytes app/assets/images/list_view_icon.jpg | Bin 357 -> 0 bytes app/assets/stylesheets/sections/events.scss | 24 ++++++++++++-------- app/helpers/events_helper.rb | 11 ++++++++- 15 files changed, 28 insertions(+), 15 deletions(-) delete mode 100644 app/assets/images/diff_file_add.png delete mode 100644 app/assets/images/diff_file_delete.png delete mode 100644 app/assets/images/diff_file_info.png delete mode 100644 app/assets/images/diff_file_notice.png delete mode 100644 app/assets/images/event_filter_comments.png delete mode 100644 app/assets/images/event_filter_merged.png delete mode 100644 app/assets/images/event_filter_push.png delete mode 100644 app/assets/images/event_filter_team.png delete mode 100644 app/assets/images/event_mr_merged.png delete mode 100644 app/assets/images/event_push.png delete mode 100644 app/assets/images/list_view_icon.jpg diff --git a/Gemfile b/Gemfile index 77b054465d0..20323f2e3e4 100644 --- a/Gemfile +++ b/Gemfile @@ -111,7 +111,7 @@ group :assets do gem "modernizr", "2.6.2" gem "raphael-rails", git: "https://github.com/gitlabhq/raphael-rails.git" gem 'bootstrap-sass', "2.2.1.1" - gem "font-awesome-sass-rails", "~> 2.0.0" + gem "font-awesome-sass-rails", "~> 3.0.0" gem "gemoji", "~> 1.2.1", require: 'emoji/railtie' end diff --git a/Gemfile.lock b/Gemfile.lock index 8fba310d4eb..58d510634e9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -174,7 +174,7 @@ GEM eventmachine (>= 0.12.0) ffaker (1.15.0) ffi (1.1.5) - font-awesome-sass-rails (2.0.0.0) + font-awesome-sass-rails (3.0.0.1) railties (>= 3.1.1) sass-rails (>= 3.1.1) foreman (0.60.2) @@ -381,7 +381,7 @@ GEM rspec-mocks (~> 2.12.0) rubyntlm (0.1.1) rubyzip (0.9.9) - sass (3.2.3) + sass (3.2.5) sass-rails (3.2.5) railties (~> 3.2.0) sass (>= 3.1.10) @@ -488,7 +488,7 @@ DEPENDENCIES email_spec factory_girl_rails ffaker - font-awesome-sass-rails (~> 2.0.0) + font-awesome-sass-rails (~> 3.0.0) foreman gemoji (~> 1.2.1) git diff --git a/app/assets/images/diff_file_add.png b/app/assets/images/diff_file_add.png deleted file mode 100644 index 0f01128df96a9f03016dd00c0103f80fde14ab72..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 177 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1G~wj^(N7l!{J zxM1({$v_d#0*}aI1_o|n5N2eUHAey{$X?><>&kwIiCe^2JfqI@98k#6)5S5w;&gJt z0;7Z@+SRik+PBTns|u~=`-SsdVJYy z_WTfHSX;d4jgIVt-%e@|rd=wDExP+Yw~OJ$^_MfgGK(&EMY06MTyX9Ws|3R$Lq&tH Re=`k1BA%{(F6*2UngA1tW?ldQ diff --git a/app/assets/images/diff_file_info.png b/app/assets/images/diff_file_info.png deleted file mode 100644 index 8529e82396a8868a30dd701d32a1025d5b3bf9f2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 749 zcmVPx#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipt+ z3N#H9*lAh-00M1EL_t(I%YBo-PZMz%#y{V?@7?zIQ6++x^Bz)ihe0W%YJ~j33E8w3jG|cF+*vPo!G(U+%?hp=N!Bh%> z+Q9)E8)*`WZAZzd)tp8;;;0U3*pOt)SPK6*GXNb2V*OG``S^LYS*!64n;-CV!c z!H1cT6n^L5PE1Tb1za5vLqkLNLZQ&;z`!7%;HF^>)IJ@PkDjs zdStR$gb)Cx1cVTR{c;(ltYhL_Na?d*E+5Yc2_OXQ?UgW1)oAfK5bW)hIQ}C6zgj(5 ztRL2U0s#ll^ZvW8X&U8niE8y=5%48YOQlj{juV({X=wq(xkvtr>$6?hB9%&w0W}@) zGnq`Wz5Qy3dsx323SB}P2D+}Fl#~*~FwixP^|c>tZEd}e$K$Voq7Ha~x4gW(7!HTS z)k@`tQi?#J2~#Ny!$1g)-JNaL*H+ow{53N@J^cd60hMFPb>ISUITDH7?dJm2|%HBo-U3d8Ta1a zILmp+LB#c;@aNB)~F}Qe@kQ+6EJ`0lAN$cG0l*3&hGvE`zrHIJvkaJ z(+{3ec4%N=WMbhEPyjQMRHcLS{5-kexb;-b(NC1;W%zQOdCJcZkA8D+x30ay%do~< zA%%ZFvd+H}5%P*%nJJnxtKFX-kwF)N#W%SAbZkJ*7JhO=Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iyw< z5E>e|PZtIN00M4FL_t(Y$F-GBh>lSd$AAB~x1o&kvA{yc*1|}N#iWsh)hv_+&m9XE zLXsjZrYtm?Qj$VR={#9j84Dj%YFH_=o5{*Xp?u_HiWt)z3-_7s`*eLY!>Omz+%~gI(*#9Ptd}$hEMXSr z-jevqvMkRkgdpIeyC0C$vOWrMcYh6xNqPW$0y=@sz%qBAC&`nFRQuk$`>JNF`I?Lx zNg4;vNjh(44d?3&8%Q$v+9|;4y>I8sR|l8{l{pb{MD# zKF3%KU^9CirR6okeo3F){e+~sz;#J)fG5eac{#D!5&=D_Q&$HIcjF<1&<5Oc_wC6=t8i8{ zV%NXddLVb7V%A(%{_9bHlU>vvxJOgf; z*;_Kh>8~w>&<)%N+F~Zp&1_}v1)7nW*)XsLcvs8h-w;HSN5BqupZL`~J}ZKXMABAZ glK*KTgw9<22g1kw?GASPt^fc407*qoM6N<$g1Qw^R{#J2 diff --git a/app/assets/images/event_filter_merged.png b/app/assets/images/event_filter_merged.png deleted file mode 100644 index 30aea0b6e55985cc8e881d952d1f4282cc80a046..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 463 zcmV;=0WkiFP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iye{ z2@)MQM<#Fp00B=)L_t(I%iWW)N&`U>B?r-G$o6;>qnTBxX}7J`_wnZUB-%q4aXEZoff`|bRG>s4j@B>kWXKTjC0O|k$002ovPDHLk FV1kZ7yrKXA diff --git a/app/assets/images/event_filter_push.png b/app/assets/images/event_filter_push.png deleted file mode 100644 index 930faee6aa2a441ab0805910cf815212f95cfe83..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 632 zcmV-;0*C#HP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iye{ z2@)=dmq%s*00H<(L_t(I%dOPEYZOrs2k_5rB!qySkQ9rWUSc5#Tck)33yF|2!Y#qG zNm8Xxy88ptd5wwDhdL)eaTyKl;~k!2x6HHe)whirusJ-#2oCWWUG#7jO^o3f3uT_YI1w-n#X45- z2JJG>-k(sxHLPI{oifjs>w?zPQ1sGJEY;j4X()zj{H-(;f6`EN`o3hK%oQw`dDf{( z>H!{Aon@YFqJ_mY6isME0zTtynP;;#Smm4Gx9<9Hd_?OPAe(@0wKX}6#Cj3vRjQL?IdvpEnqGUMXM6{6W{P9 zp0CkYRnk0`$~-%23|!pDB3gs;iqafp|3?Mv3AV~SyH~fqIuZ1BTwmQ&dbS!f+w6m# zv|yXqh>F;c3g|D`$=IHW*t4ZF&o)lo*b($Rrs6ow#0?Dx*hauknP*4Uw|@aR*tis< Sh#*h^0000002t}0ssI2w=C_w00001b5ch_0Itp) z=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iyw< z5&{UyX)1XD00g;7L_t(|+TB~rZt5@)C5}TvLWo<0D4=#j|NnQoVON1lQ4vY=bnN&p zA|Z4Gf#5L>%&v$UAJ5~=jK|tyvFJRspw6Sq<0Hhk`5Df6Q52kWA;kVeP1AH;M+oV< zey<3H5R}q9&kuneN}lH>RMRvK!?-hqS(Z^si=w#X%W)j*x^5VTX_|L{PzVvnF=MQ$ zC3DUhW43K;n%3S(BZP>es42X?Fvg-NI<#uedAks%X)3uV&UqZi`#&Y)5C&1&-l!<0 zS(eGKndf7n(+zroCS8k9BzHB$DoT zH0rd7Ef`}U9(X8}QpOm@_>cW??=~u^Reo78gy1F$wJZV*42sgDw)o+Hb;G0SPza$; zhmtG9=&&dXMF`8qWfC_S9U_D%r7GYt#t=e(Z>43mu1JTHl@wT{!5FI`3`x3&WDCo( zRJfviUWx&?;`=_Vt#Z!)KJ$jEQ`IetTIDk;P7QKTmSr7wALOOm?Y5%E-;3iofZ?<# z3deEUg%Fl77-N=YwF@DXUBP-aaBKi{MX199)}iA#aKt+rCe7!*SIdke!b z_l)Io8*DjkB@7$mQ%K!`Dx>3_p! z@Je*p@At2EMInT3+igeay6)ANDruS$LLd#QqeeW>3&XG}r*X~)g8^(Yt!iRuG#XvO zib;~Zyu85fL={3^*WcdWeBZzD&a@~B-}hf%U%|T}3a7q2&zsF=zVDX9d zo56Y@ydS1%`d=b>I`@3GRd%YeZL?*?NMHq(R zZnxXt)M}bGolZ{`K53ffc^*Yk$(c1XUP+RyR;zuDVp$d;q~Gt~4q-X?^z-vmt#@@@ zpUq}6X&0q*xm;Fr28{7=IPCZPjgsER2!#+q5Nx;G8csJ1V>+E)2a-}++H*}#_w@AS zy6%Nhw*f-Vc@PA<-R_cn1tByZkDJ<67>4Wh`VxXc2oXXEA!l)3iZBer&1TcI2QwH9 zo}ZsDQ6{ByyWIvs(2VO48V-kqkQ%!^k1)^k@9*z2JY3h0ux)!V7}&O5J@0ZzF9?D- zj<4>0bi3WjWO6EKok5tU>2kRQnN2FUQjP<6I-M-b$_Zka#08JVmG_WAj# zXix@RN}{TQL^W|`wOZW^yfVmteSK9ojA~M0MT1=GB+v6|9L6=Arfy0`of@kH|8=#6 zqUQnXELamj@e~Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iye{ z2@)MQM<#Fp00B=)L_t(I%iWW)N&`U>B?r-G$o6;>qnTBxX}7J`_wnZUB-%q4aXEZoff`|bRG>s4j@B>kWXKTjC0O|k$002ovPDHLk FV1kZ7yrKXA diff --git a/app/assets/images/event_push.png b/app/assets/images/event_push.png deleted file mode 100644 index 930faee6aa2a441ab0805910cf815212f95cfe83..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 632 zcmV-;0*C#HP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iye{ z2@)=dmq%s*00H<(L_t(I%dOPEYZOrs2k_5rB!qySkQ9rWUSc5#Tck)33yF|2!Y#qG zNm8Xxy88ptd5wwDhdL)eaTyKl;~k!2x6HHe)whirusJ-#2oCWWUG#7jO^o3f3uT_YI1w-n#X45- z2JJG>-k(sxHLPI{oifjs>w?zPQ1sGJEY;j4X()zj{H-(;f6`EN`o3hK%oQw`dDf{( z>H!{Aon@YFqJ_mY6isME0zTtynP;;#Smm4Gx9<9Hd_?OPAe(@0wKX}6#Cj3vRjQL?IdvpEnqGUMXM6{6W{P9 zp0CkYRnk0`$~-%23|!pDB3gs;iqafp|3?Mv3AV~SyH~fqIuZ1BTwmQ&dbS!f+w6m# zv|yXqh>F;c3g|D`$=IHW*t4ZF&o)lo*b($Rrs6ow#0?Dx*hauknP*4Uw|@aR*tis< Sh#*h^0000^lOiET&UP@Y7ModgWM?qOlT~kX_QeM|USHnP6LsNs1ot>SFgG-o;OISln zOiF`f@c#gVAO`~ tooltip do - image_tag "event_filter_#{key}.png" + content_tag :i, nil, class: icon_for_event[key] end end end + + def icon_for_event + { + EventFilter.push => "icon-upload-alt", + EventFilter.merged => "icon-check", + EventFilter.comments => "icon-comments", + EventFilter.team => "icon-user", + } + end end From dd20da1bfff2cd5ea43c8c3c6837bd40e5f44f4f Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 10 Jan 2013 17:38:37 +0200 Subject: [PATCH 07/32] Fix pager loading on every page in application --- app/assets/javascripts/dashboard.js.coffee | 5 +---- app/views/dashboard/index.html.haml | 3 +++ app/views/keys/create.js.haml | 9 --------- app/views/keys/new.js.haml | 11 ----------- 4 files changed, 4 insertions(+), 24 deletions(-) delete mode 100644 app/views/keys/create.js.haml delete mode 100644 app/views/keys/new.js.haml diff --git a/app/assets/javascripts/dashboard.js.coffee b/app/assets/javascripts/dashboard.js.coffee index b0ae6bf8a02..f15d09dd475 100644 --- a/app/assets/javascripts/dashboard.js.coffee +++ b/app/assets/javascripts/dashboard.js.coffee @@ -1,7 +1,4 @@ -$ -> - dashboardPage() - -dashboardPage = -> +window.dashboardPage = -> Pager.init 20, true $(".event_filter_link").bind "click", (event) -> event.preventDefault() diff --git a/app/views/dashboard/index.html.haml b/app/views/dashboard/index.html.haml index abbe3101fc3..1a66ba4fb37 100644 --- a/app/views/dashboard/index.html.haml +++ b/app/views/dashboard/index.html.haml @@ -7,3 +7,6 @@ - else = render "zero_authorized_projects" + +:javascript + dashboardPage(); diff --git a/app/views/keys/create.js.haml b/app/views/keys/create.js.haml deleted file mode 100644 index 1dccf6fdb91..00000000000 --- a/app/views/keys/create.js.haml +++ /dev/null @@ -1,9 +0,0 @@ -- if @key.valid? - :plain - $("#new_key_dialog").dialog("close"); - $("#keys-table .data").append("#{escape_javascript(render(partial: 'show', locals: {key: @key}))}"); - $("#no_ssh_key_defined").hide(); -- else - :plain - $("#new_key_dialog").empty(); - $("#new_key_dialog").append("#{escape_javascript(render('form'))}"); diff --git a/app/views/keys/new.js.haml b/app/views/keys/new.js.haml deleted file mode 100644 index 86e9db030c5..00000000000 --- a/app/views/keys/new.js.haml +++ /dev/null @@ -1,11 +0,0 @@ -:plain - var new_key_dialog = $("
"); - new_key_dialog.html("#{escape_javascript(render('form'))}"); - $(new_key_dialog).dialog({ - width: 350, - resizable: false, - draggable: false, - title: "Add new public key", - close: function(event, ui) { $("#new_key_dialog").remove();}, - modal: true - }); From e25656d09bea03892a1d7720cdd70894db7805aa Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 10 Jan 2013 18:09:12 +0200 Subject: [PATCH 08/32] Improve wiki typography --- .../stylesheets/gitlab_bootstrap/files.scss | 23 ++++--------------- .../gitlab_bootstrap/typography.scss | 19 +++++++++++++++ app/views/issues/show.html.haml | 5 ++-- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/app/assets/stylesheets/gitlab_bootstrap/files.scss b/app/assets/stylesheets/gitlab_bootstrap/files.scss index 83954da525a..865a10e1fd7 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/files.scss +++ b/app/assets/stylesheets/gitlab_bootstrap/files.scss @@ -37,24 +37,6 @@ background: #fff; font-size: 11px; - &.wiki { - font-size: 13px; - code { - padding: 0 4px; - } - padding: 20px; - - h1 { font-size: 26px; line-height: 46px; } - h2 { font-size: 22px; line-height: 42px; } - h3 { font-size: 20px; line-height: 40px; } - h4 { font-size: 18px; line-height: 32px; } - h5 { font-size: 16px; line-height: 26px; } - - .white .highlight pre { - background: #f5f5f5; - } - } - &.image_file { background: #eee; text-align: center; @@ -64,6 +46,11 @@ } } + &.wiki { + padding: 20px; + font-size: 13px; + } + &.blob_file { } diff --git a/app/assets/stylesheets/gitlab_bootstrap/typography.scss b/app/assets/stylesheets/gitlab_bootstrap/typography.scss index 81fb79a43f2..e74a0de125b 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/typography.scss +++ b/app/assets/stylesheets/gitlab_bootstrap/typography.scss @@ -81,3 +81,22 @@ a:focus { .monospace { font-family: 'Menlo', 'Liberation Mono', 'Consolas', 'Courier New', 'andale mono','lucida console',monospace; } + +/** + * Wiki typography + * + */ +.wiki { + font-size: 13px; + + code { padding: 0 4px; } + p { font-size: 13px; } + h1 { font-size: 32px; line-height: 40px; margin: 10px 0;} + h2 { font-size: 26px; line-height: 40px; margin: 10px 0;} + h3 { font-size: 22px; line-height: 40px; margin: 10px 0;} + h4 { font-size: 18px; line-height: 20px; margin: 10px 0;} + h5 { font-size: 14px; line-height: 20px; margin: 10px 0;} + h6 { font-size: 12px; line-height: 20px; margin: 10px 0;} + .white .highlight pre { background: #f5f5f5; } + ul { margin: 0 0 9px 25px !important; } +} diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index b96af36fcc0..10f647de3d2 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -51,8 +51,9 @@ - if @issue.description.present? .ui-box-bottom - = preserve do - = markdown @issue.description + .wiki + = preserve do + = markdown @issue.description .issue_notes.voting_notes#notes= render "notes/notes_with_form", tid: @issue.id, tt: "issue" From 9152ab79554b251c7e90ecd99ece67deff55ae92 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 10 Jan 2013 20:20:56 +0200 Subject: [PATCH 09/32] Fix missing image for last push --- app/views/events/_event_last_push.html.haml | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/views/events/_event_last_push.html.haml b/app/views/events/_event_last_push.html.haml index b2376019c8e..2c2f270cf6c 100644 --- a/app/views/events/_event_last_push.html.haml +++ b/app/views/events/_event_last_push.html.haml @@ -1,7 +1,5 @@ - if show_last_push_widget?(event) .event_lp - = image_tag "event_push.png" -   %span You pushed to = link_to project_commits_path(event.project, event.ref_name) do %strong= truncate(event.ref_name, length: 28) From f97ae2ff854fe74f2fa350ad2f179443fffa66b4 Mon Sep 17 00:00:00 2001 From: Martin Bastien Date: Thu, 10 Jan 2013 15:55:34 -0500 Subject: [PATCH 10/32] Fix for archive download (method path missing) --- app/models/repository.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/repository.rb b/app/models/repository.rb index cf8ba4530a1..6bfdf2255f2 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -151,12 +151,12 @@ class Repository return nil unless commit # Build file path - file_name = self.path + "-" + commit.id.to_s + ".tar.gz" - storage_path = Rails.root.join("tmp", "repositories", self.path_with_namespace) + file_name = self.path_with_namespace + "-" + commit.id.to_s + ".tar.gz" + storage_path = Rails.root.join("tmp", "repositories") file_path = File.join(storage_path, file_name) # Put files into a directory before archiving - prefix = self.path + "/" + prefix = self.path_with_namespace + "/" # Create file if not exists unless File.exists?(file_path) From c913f40ca45c4ba66fb98ad2587f12244bc3a33a Mon Sep 17 00:00:00 2001 From: MrHammy Date: Fri, 11 Jan 2013 13:40:29 +0100 Subject: [PATCH 11/32] Update app/views/wikis/pages.html.haml Changed the link in the pages of the wiki to the direct link instead of the first created page --- app/views/wikis/pages.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/wikis/pages.html.haml b/app/views/wikis/pages.html.haml index 7421d8f9675..04253a8963b 100644 --- a/app/views/wikis/pages.html.haml +++ b/app/views/wikis/pages.html.haml @@ -10,7 +10,7 @@ - @wikis.each_with_index do |wiki_page, i| %tr %td - = link_to wiki_page.title, project_wiki_path(@project, wiki_page, old_page_id: wiki_page.id) + = link_to wiki_page.title, project_wiki_path(@project, wiki_page) (#{time_ago_in_words(wiki_page.created_at)} ago) %td= wiki_page.slug From 97a4e1b86ace4b338bba345ea54166503fe0048d Mon Sep 17 00:00:00 2001 From: David Southard Date: Thu, 10 Jan 2013 13:21:54 -0600 Subject: [PATCH 12/32] update grammar in check application status section --- doc/install/installation.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/install/installation.md b/doc/install/installation.md index 7fb5e48cdc9..29ca7a812ca 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -280,9 +280,8 @@ To make sure you didn't miss anything run a more thorough check with: sudo -u gitlab -H bundle exec rake gitlab:check RAILS_ENV=production -If you are all green: congratulations, you successfully installed GitLab! -Although this is the case, there are still a few steps to go. - +If all items are green, then congratulations on successfully installing GitLab! +However there are still a few steps left. ## Install Init Script From f0c4e94d7406cb30c77b1f3dd20f541a9398588a Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Fri, 11 Jan 2013 18:58:13 +0100 Subject: [PATCH 13/32] Move checks after init script installation in docs --- doc/install/installation.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/doc/install/installation.md b/doc/install/installation.md index 29ca7a812ca..6a7605cb36d 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -270,6 +270,18 @@ used for the `email.from` setting in `config/gitlab.yml`) sudo -u gitlab -H bundle exec rake gitlab:app:setup RAILS_ENV=production +## Install Init Script + +Download the init script (will be /etc/init.d/gitlab): + + sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab -P /etc/init.d/ + sudo chmod +x /etc/init.d/gitlab + +Make GitLab start on boot: + + sudo update-rc.d gitlab defaults 21 + + ## Check Application Status Check if GitLab and its environment is configured correctly: @@ -283,19 +295,7 @@ To make sure you didn't miss anything run a more thorough check with: If all items are green, then congratulations on successfully installing GitLab! However there are still a few steps left. -## Install Init Script - -Download the init script (will be /etc/init.d/gitlab): - - sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab -P /etc/init.d/ - sudo chmod +x /etc/init.d/gitlab - -Make GitLab start on boot: - - sudo update-rc.d gitlab defaults 21 - - -Start your GitLab instance: +## Start Your GitLab Instance sudo service gitlab start # or From 5aada8cc2adef82780e23b859aeabb71f7d1f5ca Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Fri, 11 Jan 2013 20:03:43 +0100 Subject: [PATCH 14/32] Move wiki delete button to the edit page --- app/views/wikis/edit.html.haml | 5 +++++ app/views/wikis/show.html.haml | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/views/wikis/edit.html.haml b/app/views/wikis/edit.html.haml index 27d2a8f915f..8f6b457f22a 100644 --- a/app/views/wikis/edit.html.haml +++ b/app/views/wikis/edit.html.haml @@ -1,3 +1,8 @@ %h3.page_title Editing page %hr = render 'form' + +.right + - if can? current_user, :admin_wiki, @project + = link_to project_wiki_path(@project, @wiki), confirm: "Are you sure you want to delete this page?", method: :delete, class: "btn small danger" do + Delete this page \ No newline at end of file diff --git a/app/views/wikis/show.html.haml b/app/views/wikis/show.html.haml index c3074539054..2995602017f 100644 --- a/app/views/wikis/show.html.haml +++ b/app/views/wikis/show.html.haml @@ -16,6 +16,3 @@ = markdown @wiki.content %p.time Last edited by #{@wiki.user.name}, #{time_ago_in_words @wiki.created_at} ago -- if can? current_user, :admin_wiki, @project - = link_to project_wiki_path(@project, @wiki), confirm: "Are you sure you want to delete this page?", method: :delete do - Delete this page From 167f26b90d5b4d4b0306a6f0721444c4132141d8 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Fri, 11 Jan 2013 20:04:14 +0100 Subject: [PATCH 15/32] Add an ordering scope to Wiki --- app/controllers/wikis_controller.rb | 16 ++++++++-------- app/models/wiki.rb | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/controllers/wikis_controller.rb b/app/controllers/wikis_controller.rb index a93afe114df..1ca7e4af24d 100644 --- a/app/controllers/wikis_controller.rb +++ b/app/controllers/wikis_controller.rb @@ -2,16 +2,16 @@ class WikisController < ProjectResourceController before_filter :authorize_read_wiki! before_filter :authorize_write_wiki!, only: [:edit, :create, :history] before_filter :authorize_admin_wiki!, only: :destroy - + def pages - @wikis = @project.wikis.group(:slug).order("created_at") + @wiki_pages = @project.wikis.group(:slug).ordered end def show - if params[:old_page_id] - @wiki = @project.wikis.find(params[:old_page_id]) + if params[:version_id] + @wiki = @project.wikis.find(params[:version_id]) else - @wiki = @project.wikis.where(slug: params[:id]).order("created_at").last + @wiki = @project.wikis.where(slug: params[:id]).ordered.first end @note = @project.notes.new(noteable: @wiki) @@ -29,7 +29,7 @@ class WikisController < ProjectResourceController end def edit - @wiki = @project.wikis.where(slug: params[:id]).order("created_at").last + @wiki = @project.wikis.where(slug: params[:id]).ordered.first @wiki = Wiki.regenerate_from @wiki end @@ -47,9 +47,9 @@ class WikisController < ProjectResourceController end def history - @wikis = @project.wikis.where(slug: params[:id]).order("created_at") + @wiki_pages = @project.wikis.where(slug: params[:id]).ordered end - + def destroy @wikis = @project.wikis.where(slug: params[:id]).delete_all diff --git a/app/models/wiki.rb b/app/models/wiki.rb index 4f113957f99..7f488ca7625 100644 --- a/app/models/wiki.rb +++ b/app/models/wiki.rb @@ -25,6 +25,8 @@ class Wiki < ActiveRecord::Base before_update :set_slug + scope :ordered, order("created_at DESC") + def to_param slug end From b3bfb75252b9feaaab7fa5969b9c9bb4b34d864e Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Fri, 11 Jan 2013 20:16:37 +0100 Subject: [PATCH 16/32] Fix link_to_member to not be bold by default --- app/helpers/projects_helper.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 425dd471b36..f7325791579 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -26,19 +26,17 @@ module ProjectsHelper # Build avatar image tag avatar = image_tag(gravatar_icon(author.try(:email)), width: 16, class: "lil_av") - # Build name strong tag - name = content_tag :strong, author.name, class: 'author' + # Build name span tag + name = content_tag :span, author.name, class: 'author' author_html = avatar + name tm = project.team_member_by_id(author) - content_tag :span, class: 'member-link' do - if tm - link_to author_html, project_team_member_path(project, tm), class: "author_link" - else - author_html - end + if tm + link_to author_html, project_team_member_path(project, tm), class: "author_link" + else + author_html end end From b55ed840e63088e28127f9989fc69d49345a0083 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Fri, 11 Jan 2013 20:20:11 +0100 Subject: [PATCH 17/32] Update wiki pages * Properly name columns in Pages and History views * Link to Authors * Make views more consistent --- app/views/wikis/history.html.haml | 21 ++++++++++++--------- app/views/wikis/pages.html.haml | 18 ++++++++++-------- app/views/wikis/show.html.haml | 2 +- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/app/views/wikis/history.html.haml b/app/views/wikis/history.html.haml index 0a81817c5e7..18df8e1d71b 100644 --- a/app/views/wikis/history.html.haml +++ b/app/views/wikis/history.html.haml @@ -1,20 +1,23 @@ %h3.page_title %span.cgray History for - = @wikis.last.title + = @wiki_pages.first.title %br %table %thead %tr - %th # - %th last edit - %th created by + %th Page version + %th Last updated + %th Updated by %tbody - - @wikis.each_with_index do |wiki_page, i| + - @wiki_pages.each_with_index do |wiki_page, i| %tr - %td= i + 1 %td - = link_to wiki_page.created_at.to_s(:short), project_wiki_path(@project, wiki_page, old_page_id: wiki_page.id) + %strong + = link_to project_wiki_path(@project, wiki_page, version_id: wiki_page.id) do + Version + = @wiki_pages.count - i + %td + = wiki_page.created_at.to_s(:short) (#{time_ago_in_words(wiki_page.created_at)} ago) - %td= wiki_page.user.name - + %td= link_to_member(@project, wiki_page.user) diff --git a/app/views/wikis/pages.html.haml b/app/views/wikis/pages.html.haml index 04253a8963b..2e0f091ce72 100644 --- a/app/views/wikis/pages.html.haml +++ b/app/views/wikis/pages.html.haml @@ -4,15 +4,17 @@ %thead %tr %th Title - %th slug - %th created by + %th Slug + %th Last updated + %th Updated by %tbody - - @wikis.each_with_index do |wiki_page, i| + - @wiki_pages.each do |wiki_page| %tr %td - = link_to wiki_page.title, project_wiki_path(@project, wiki_page) - (#{time_ago_in_words(wiki_page.created_at)} - ago) + %strong= link_to wiki_page.title, project_wiki_path(@project, wiki_page) %td= wiki_page.slug - %td= wiki_page.user.name - + %td + = wiki_page.created_at.to_s(:short) do + (#{time_ago_in_words(wiki_page.created_at)} + ago) + %td= link_to_member(@project, wiki_page.user) diff --git a/app/views/wikis/show.html.haml b/app/views/wikis/show.html.haml index 2995602017f..ea23f62c262 100644 --- a/app/views/wikis/show.html.haml +++ b/app/views/wikis/show.html.haml @@ -15,4 +15,4 @@ = preserve do = markdown @wiki.content -%p.time Last edited by #{@wiki.user.name}, #{time_ago_in_words @wiki.created_at} ago +%p.time Last edited by #{link_to_member @project, @wiki.user}, #{time_ago_in_words @wiki.created_at} ago From fd836f5490dbc05b84895f4d3736bfa572f80911 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Fri, 11 Jan 2013 21:04:21 +0100 Subject: [PATCH 18/32] Update empty error messages and warn if not viewing the most recent wiki page --- app/assets/stylesheets/common.scss | 13 +++++++++++++ app/controllers/wikis_controller.rb | 5 ++--- app/views/wikis/empty.html.haml | 4 ++-- app/views/wikis/show.html.haml | 5 +++++ 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index b72c9e93d9e..f7a93436b3c 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -446,6 +446,19 @@ li.note { } } +.warning_message { + border-left: 4px solid #ed9; + color: #b90; + padding: 10px; + margin-bottom: 10px; + background: #ffffe6; + padding-left: 20px; + + &.centered { + text-align: center; + } +} + .oauth_select_holder { padding: 20px; img { diff --git a/app/controllers/wikis_controller.rb b/app/controllers/wikis_controller.rb index 1ca7e4af24d..69280291003 100644 --- a/app/controllers/wikis_controller.rb +++ b/app/controllers/wikis_controller.rb @@ -8,14 +8,13 @@ class WikisController < ProjectResourceController end def show + @most_recent_wiki = @project.wikis.where(slug: params[:id]).ordered.first if params[:version_id] @wiki = @project.wikis.find(params[:version_id]) else - @wiki = @project.wikis.where(slug: params[:id]).ordered.first + @wiki = @most_recent_wiki end - @note = @project.notes.new(noteable: @wiki) - if @wiki render 'show' else diff --git a/app/views/wikis/empty.html.haml b/app/views/wikis/empty.html.haml index 32b1c9258c5..08b59f0328b 100644 --- a/app/views/wikis/empty.html.haml +++ b/app/views/wikis/empty.html.haml @@ -1,4 +1,4 @@ %h3.page_title Empty page %hr -.alert-message.block-message.warning - %span You are not allowed to create wiki pages +.error_message + You are not allowed to create wiki pages diff --git a/app/views/wikis/show.html.haml b/app/views/wikis/show.html.haml index ea23f62c262..d3bd58bbeec 100644 --- a/app/views/wikis/show.html.haml +++ b/app/views/wikis/show.html.haml @@ -10,6 +10,11 @@ %i.icon-edit Edit %br +- if @wiki != @most_recent_wiki + .warning_message + This is an old version of this page. + You can view the #{link_to "most recent version", project_wiki_path(@project, @wiki)} or browse the #{link_to "history", history_project_wiki_path(@project, @wiki)}. + .file_holder .file_content.wiki = preserve do From a213d4b9e80fed7a8ad38185d2a93e6def295e50 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Sat, 12 Jan 2013 01:24:51 +0100 Subject: [PATCH 19/32] Move OS detection to task helpers and add detection of OS X --- lib/tasks/gitlab/info.rake | 14 -------------- lib/tasks/gitlab/task_helpers.rake | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/lib/tasks/gitlab/info.rake b/lib/tasks/gitlab/info.rake index fd3e83e8338..4b906684dcd 100644 --- a/lib/tasks/gitlab/info.rake +++ b/lib/tasks/gitlab/info.rake @@ -3,20 +3,6 @@ namespace :gitlab do desc "GITLAB | Show information about GitLab and its environment" task info: :environment do - # check which OS is running - os_name = run("lsb_release -irs") - os_name ||= if File.readable?('/etc/system-release') - File.read('/etc/system-release') - end - os_name ||= if File.readable?('/etc/debian_version') - debian_version = File.read('/etc/debian_version') - "Debian #{debian_version}" - end - os_name ||= if File.readable?('/etc/SuSE-release') - File.read('/etc/SuSE-release') - end - os_name.try(:squish!) - # check if there is an RVM environment rvm_version = run_and_match("rvm --version", /[\d\.]+/).try(:to_s) # check Ruby version diff --git a/lib/tasks/gitlab/task_helpers.rake b/lib/tasks/gitlab/task_helpers.rake index c9635f058ee..5b5c3c30ba2 100644 --- a/lib/tasks/gitlab/task_helpers.rake +++ b/lib/tasks/gitlab/task_helpers.rake @@ -1,5 +1,27 @@ namespace :gitlab do + # Check which OS is running + # + # It will primarily use lsb_relase to determine the OS. + # It has fallbacks to Debian, SuSE and OS X. + def os_name + os_name = run("lsb_release -irs") + os_name ||= if File.readable?('/etc/system-release') + File.read('/etc/system-release') + end + os_name ||= if File.readable?('/etc/debian_version') + debian_version = File.read('/etc/debian_version') + "Debian #{debian_version}" + end + os_name ||= if File.readable?('/etc/SuSE-release') + File.read('/etc/SuSE-release') + end + os_name ||= if os_x_version = run("sw_vers -productVersion") + "Mac OS X #{os_x_version}" + end + os_name.try(:squish!) + end + # Runs the given command and matches the output agains the given pattern # # Returns nil if nothing matched From 4d0af232da7df8c4a33b9f2e44933f1f3d2527bc Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Fri, 11 Jan 2013 22:25:18 +0100 Subject: [PATCH 20/32] Make method names clearer in check.rake --- lib/tasks/gitlab/check.rake | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index 665973e2303..40a572c6a3c 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -317,7 +317,7 @@ namespace :gitlab do gitolite_ssh_user = Gitlab.config.gitolite.ssh_user print "Has no \"-e\" in ~#{gitolite_ssh_user}/.profile ... " - profile_file = File.join(gitolite_home, ".profile") + profile_file = File.join(gitolite_user_home, ".profile") unless File.read(profile_file) =~ /^-e PATH/ puts "yes".green @@ -475,7 +475,7 @@ namespace :gitlab do def check_dot_gitolite_exists print "Config directory exists? ... " - gitolite_config_path = File.join(gitolite_home, ".gitolite") + gitolite_config_path = File.join(gitolite_user_home, ".gitolite") if File.directory?(gitolite_config_path) puts "yes".green @@ -496,7 +496,7 @@ namespace :gitlab do def check_dot_gitolite_permissions print "Config directory access is drwxr-x---? ... " - gitolite_config_path = File.join(gitolite_home, ".gitolite") + gitolite_config_path = File.join(gitolite_user_home, ".gitolite") unless File.exists?(gitolite_config_path) puts "can't check because of previous errors".magenta return @@ -520,7 +520,7 @@ namespace :gitlab do gitolite_ssh_user = Gitlab.config.gitolite.ssh_user print "Config directory owned by #{gitolite_ssh_user}:#{gitolite_ssh_user} ... " - gitolite_config_path = File.join(gitolite_home, ".gitolite") + gitolite_config_path = File.join(gitolite_user_home, ".gitolite") unless File.exists?(gitolite_config_path) puts "can't check because of previous errors".magenta return @@ -559,7 +559,7 @@ namespace :gitlab do end def check_gitoliterc_git_config_keys - gitoliterc_path = File.join(gitolite_home, ".gitolite.rc") + gitoliterc_path = File.join(gitolite_user_home, ".gitolite.rc") print "Allow all Git config keys in .gitolite.rc ... " option_name = if has_gitolite3? @@ -588,7 +588,7 @@ namespace :gitlab do end def check_gitoliterc_repo_umask - gitoliterc_path = File.join(gitolite_home, ".gitolite.rc") + gitoliterc_path = File.join(gitolite_user_home, ".gitolite.rc") print "Repo umask is 0007 in .gitolite.rc? ... " option_name = if has_gitolite3? @@ -726,7 +726,6 @@ namespace :gitlab do puts "yes".green else puts "no".red - puts "#{repo_base_path} is not writable".red try_fixing_it( "sudo chmod -R ug+rwXs,o-rwx #{repo_base_path}" ) @@ -852,12 +851,12 @@ namespace :gitlab do # Helper methods ######################## - def gitolite_home + def gitolite_user_home File.expand_path("~#{Gitlab.config.gitolite.ssh_user}") end def gitolite_version - gitolite_version_file = "#{gitolite_home}/gitolite/src/VERSION" + gitolite_version_file = "#{gitolite_user_home}/gitolite/src/VERSION" if File.readable?(gitolite_version_file) File.read(gitolite_version_file) end From eb626edd3fe2602321080e231cf748afc86d4700 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Sat, 12 Jan 2013 00:44:40 +0100 Subject: [PATCH 21/32] Replace all stat command line calls with ruby equivalents --- lib/tasks/gitlab/check.rake | 17 ++++++++--------- lib/tasks/gitlab/task_helpers.rake | 9 +++++++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index 40a572c6a3c..623028b16d2 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -502,7 +502,7 @@ namespace :gitlab do return end - if `stat --printf %a #{gitolite_config_path}` == "750" + if File.stat(gitolite_config_path).mode.to_s(8).ends_with?("750") puts "yes".green else puts "no".red @@ -526,12 +526,11 @@ namespace :gitlab do return end - if `stat --printf %U #{gitolite_config_path}` == gitolite_ssh_user && # user - `stat --printf %G #{gitolite_config_path}` == gitolite_ssh_user #group + if File.stat(gitolite_config_path).uid == uid_for(gitolite_ssh_user) && + File.stat(gitolite_config_path).gid == gid_for(gitolite_ssh_user) puts "yes".green else puts "no".red - puts "#{gitolite_config_path} is not owned by #{gitolite_ssh_user}".red try_fixing_it( "sudo chown -R #{gitolite_ssh_user}:#{gitolite_ssh_user} #{gitolite_config_path}" ) @@ -722,7 +721,7 @@ namespace :gitlab do return end - if `stat --printf %a #{repo_base_path}` == "6770" + if File.stat(repo_base_path).mode.to_s(8).ends_with?("6770") puts "yes".green else puts "no".red @@ -746,12 +745,11 @@ namespace :gitlab do return end - if `stat --printf %U #{repo_base_path}` == gitolite_ssh_user && # user - `stat --printf %G #{repo_base_path}` == gitolite_ssh_user #group + if File.stat(repo_base_path).uid == uid_for(gitolite_ssh_user) && + File.stat(repo_base_path).gid == gid_for(gitolite_ssh_user) puts "yes".green else puts "no".red - puts "#{repo_base_path} is not owned by #{gitolite_ssh_user}".red try_fixing_it( "sudo chown -R #{gitolite_ssh_user}:#{gitolite_ssh_user} #{repo_base_path}" ) @@ -832,7 +830,8 @@ namespace :gitlab do next end - if run_and_match("stat --format %N #{project_hook_file}", /#{hook_file}.+->.+#{gitolite_hook_file}/) + if File.lstat(project_hook_file).symlink? && + File.realpath(project_hook_file) == File.realpath(gitolite_hook_file) puts "ok".green else puts "not a link to Gitolite's hook".red diff --git a/lib/tasks/gitlab/task_helpers.rake b/lib/tasks/gitlab/task_helpers.rake index 5b5c3c30ba2..5dd97fa2f92 100644 --- a/lib/tasks/gitlab/task_helpers.rake +++ b/lib/tasks/gitlab/task_helpers.rake @@ -45,6 +45,15 @@ namespace :gitlab do end end + def uid_for(user_name) + run("id -u #{user_name}").chomp.to_i + end + + def gid_for(group_name) + group_line = File.read("/etc/group").lines.select{|l| l.start_with?("#{group_name}:")}.first + group_line.split(":")[2].to_i + end + def warn_user_is_not_gitlab unless @warned_user_not_gitlab current_user = run("whoami").chomp From 4c6224aad173a26f1fbe20588b4b155f031d779f Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 10 Jan 2013 20:17:57 +0200 Subject: [PATCH 22/32] Public git read-only access via http --- app/controllers/public/projects_controller.rb | 11 +++++++++++ app/models/project.rb | 2 +- app/views/admin/projects/_form.html.haml | 7 +++++++ app/views/admin/projects/show.html.haml | 7 +++++++ app/views/layouts/public.html.haml | 17 +++++++++++++++++ app/views/public/projects/index.html.haml | 14 ++++++++++++++ config/routes.rb | 8 ++++++++ .../20130110172407_add_public_to_project.rb | 5 +++++ db/schema.rb | 17 +++++++++-------- lib/gitlab/backend/grack_auth.rb | 16 ++++++++++------ 10 files changed, 89 insertions(+), 15 deletions(-) create mode 100644 app/controllers/public/projects_controller.rb create mode 100644 app/views/layouts/public.html.haml create mode 100644 app/views/public/projects/index.html.haml create mode 100644 db/migrate/20130110172407_add_public_to_project.rb diff --git a/app/controllers/public/projects_controller.rb b/app/controllers/public/projects_controller.rb new file mode 100644 index 00000000000..e53c1a48485 --- /dev/null +++ b/app/controllers/public/projects_controller.rb @@ -0,0 +1,11 @@ +class Public::ProjectsController < ApplicationController + skip_before_filter :authenticate_user!, + :reject_blocked, :set_current_user_for_observers, + :add_abilities + + layout 'public' + + def index + @projects = Project.where(public: true) + end +end diff --git a/app/models/project.rb b/app/models/project.rb index 32b951349a9..ece7da26e75 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -28,7 +28,7 @@ class Project < ActiveRecord::Base attr_accessible :name, :path, :description, :default_branch, :issues_enabled, :wall_enabled, :merge_requests_enabled, :wiki_enabled, as: [:default, :admin] - attr_accessible :namespace_id, :creator_id, as: :admin + attr_accessible :namespace_id, :creator_id, :public, as: :admin attr_accessor :error_code diff --git a/app/views/admin/projects/_form.html.haml b/app/views/admin/projects/_form.html.haml index 36c0c655cae..0c7cf68ef43 100644 --- a/app/views/admin/projects/_form.html.haml +++ b/app/views/admin/projects/_form.html.haml @@ -43,6 +43,13 @@ = f.label :wiki_enabled, "Wiki" .input= f.check_box :wiki_enabled + %fieldset.features + %legend Public mode: + .clearfix + = f.label :public do + %span Allow public http clone + .input= f.check_box :public + %fieldset.features %legend Transfer: .control-group diff --git a/app/views/admin/projects/show.html.haml b/app/views/admin/projects/show.html.haml index 5a745f58fe3..8e0d82328df 100644 --- a/app/views/admin/projects/show.html.haml +++ b/app/views/admin/projects/show.html.haml @@ -77,6 +77,13 @@ SSH: %td = link_to @project.ssh_url_to_repo + - if @project.public + %tr.bgred + %td + %b + Public Read-Only Code access: + %td + = check_box_tag 'public', nil, @project.public - if @repository %table.zebra-striped diff --git a/app/views/layouts/public.html.haml b/app/views/layouts/public.html.haml new file mode 100644 index 00000000000..e82459c1e29 --- /dev/null +++ b/app/views/layouts/public.html.haml @@ -0,0 +1,17 @@ +!!! 5 +%html{ lang: "en"} + = render "layouts/head", title: "Error" + %body{class: "#{app_theme} application"} + %header.navbar.navbar-static-top.navbar-gitlab + .navbar-inner + .container + %div.app_logo + %span.separator + = link_to public_root_path, class: "home" do + %h1 GITLAB + %span.separator + %h1.project_name Public + .container + .content + .prepend-top-20 + = yield diff --git a/app/views/public/projects/index.html.haml b/app/views/public/projects/index.html.haml new file mode 100644 index 00000000000..ba4fd72628f --- /dev/null +++ b/app/views/public/projects/index.html.haml @@ -0,0 +1,14 @@ +%h3.page_title + Projects + %small Read-Only Access +%hr + +%ul.well-list + - @projects.each do |project| + %li.clearfix + %h5 + %i.icon-star.cgreen + = project.name_with_namespace + .right + %span.monospace.tiny + git clone #{project.http_url_to_repo} diff --git a/config/routes.rb b/config/routes.rb index ffcfd1ee6f5..eeba31d5ae4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -36,6 +36,14 @@ Gitlab::Application.routes.draw do get 'help/ssh' => 'help#ssh' get 'help/raketasks' => 'help#raketasks' + # + # Public namespace + # + namespace :public do + resources :projects, only: [:index] + root to: "projects#index" + end + # # Admin Area # diff --git a/db/migrate/20130110172407_add_public_to_project.rb b/db/migrate/20130110172407_add_public_to_project.rb new file mode 100644 index 00000000000..45edba48152 --- /dev/null +++ b/db/migrate/20130110172407_add_public_to_project.rb @@ -0,0 +1,5 @@ +class AddPublicToProject < ActiveRecord::Migration + def change + add_column :projects, :public, :boolean, default: false, null: false + end +end diff --git a/db/schema.rb b/db/schema.rb index b1cf0ccbdb2..4b3a2243609 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130102143055) do +ActiveRecord::Schema.define(:version => 20130110172407) do create_table "events", :force => true do |t| t.string "target_type" @@ -145,16 +145,17 @@ ActiveRecord::Schema.define(:version => 20130102143055) do t.string "name" t.string "path" t.text "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.boolean "private_flag", :default => true, :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.boolean "private_flag", :default => true, :null => false t.integer "creator_id" t.string "default_branch" - t.boolean "issues_enabled", :default => true, :null => false - t.boolean "wall_enabled", :default => true, :null => false - t.boolean "merge_requests_enabled", :default => true, :null => false - t.boolean "wiki_enabled", :default => true, :null => false + t.boolean "issues_enabled", :default => true, :null => false + t.boolean "wall_enabled", :default => true, :null => false + t.boolean "merge_requests_enabled", :default => true, :null => false + t.boolean "wiki_enabled", :default => true, :null => false t.integer "namespace_id" + t.boolean "public", :default => false, :null => false end add_index "projects", ["creator_id"], :name => "index_projects_on_owner_id" diff --git a/lib/gitlab/backend/grack_auth.rb b/lib/gitlab/backend/grack_auth.rb index cfad532a06c..0defee2b11c 100644 --- a/lib/gitlab/backend/grack_auth.rb +++ b/lib/gitlab/backend/grack_auth.rb @@ -3,6 +3,16 @@ module Grack attr_accessor :user, :project def valid? + # Find project by PATH_INFO from env + if m = /^\/([\w\.\/-]+)\.git/.match(@request.path_info).to_a + self.project = Project.find_with_namespace(m.last) + return false unless project + end + + if @request.get? && project.public + return true + end + # Authentication with username and password login, password = @auth.credentials @@ -17,12 +27,6 @@ module Grack # Pass Gitolite update hook ENV['GL_BYPASS_UPDATE_HOOK'] = "true" - # Find project by PATH_INFO from env - if m = /^\/([\w\.\/-]+)\.git/.match(@request.path_info).to_a - self.project = Project.find_with_namespace(m.last) - return false unless project - end - # Git upload and receive if @request.get? validate_get_request From 122acb2254c94823bd7b7b64aa1bd953df5fdf66 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 12 Jan 2013 21:54:52 +0200 Subject: [PATCH 23/32] fix unauth for public --- app/controllers/public/projects_controller.rb | 2 +- app/models/project.rb | 1 + app/views/layouts/_head.html.haml | 18 ++++++++++-------- app/views/layouts/public.html.haml | 6 +++--- app/views/public/projects/index.html.haml | 2 +- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/controllers/public/projects_controller.rb b/app/controllers/public/projects_controller.rb index e53c1a48485..28f46c6f239 100644 --- a/app/controllers/public/projects_controller.rb +++ b/app/controllers/public/projects_controller.rb @@ -6,6 +6,6 @@ class Public::ProjectsController < ApplicationController layout 'public' def index - @projects = Project.where(public: true) + @projects = Project.public end end diff --git a/app/models/project.rb b/app/models/project.rb index ece7da26e75..a826e04eac8 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -81,6 +81,7 @@ class Project < ActiveRecord::Base scope :sorted_by_activity, ->() { order("(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC") } scope :personal, ->(user) { where(namespace_id: user.namespace_id) } scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) } + scope :public, where(public: true) class << self def active diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml index 9d035f0e012..4b4f5da3324 100644 --- a/app/views/layouts/_head.html.haml +++ b/app/views/layouts/_head.html.haml @@ -6,12 +6,14 @@ = favicon_link_tag 'favicon.ico' = stylesheet_link_tag "application" = javascript_include_tag "application" - -# Atom feed - - if controller_name == 'projects' && action_name == 'index' - = auto_discovery_link_tag :atom, projects_url(:atom, private_token: current_user.private_token), title: "Dashboard feed" - - if @project && !@project.new_record? - - if current_controller?(:tree, :commits) - = auto_discovery_link_tag(:atom, project_commits_url(@project, @ref, format: :atom, private_token: current_user.private_token), title: "Recent commits to #{@project.name}:#{@ref}") - - if current_controller?(:issues) - = auto_discovery_link_tag(:atom, project_issues_url(@project, :atom, private_token: current_user.private_token), title: "#{@project.name} issues") = csrf_meta_tags + + -# Atom feed + - if current_user + - if controller_name == 'projects' && action_name == 'index' + = auto_discovery_link_tag :atom, projects_url(:atom, private_token: current_user.private_token), title: "Dashboard feed" + - if @project && !@project.new_record? + - if current_controller?(:tree, :commits) + = auto_discovery_link_tag(:atom, project_commits_url(@project, @ref, format: :atom, private_token: current_user.private_token), title: "Recent commits to #{@project.name}:#{@ref}") + - if current_controller?(:issues) + = auto_discovery_link_tag(:atom, project_issues_url(@project, :atom, private_token: current_user.private_token), title: "#{@project.name} issues") diff --git a/app/views/layouts/public.html.haml b/app/views/layouts/public.html.haml index e82459c1e29..864b854c757 100644 --- a/app/views/layouts/public.html.haml +++ b/app/views/layouts/public.html.haml @@ -1,16 +1,16 @@ !!! 5 %html{ lang: "en"} - = render "layouts/head", title: "Error" + = render "layouts/head", title: "Public Area" %body{class: "#{app_theme} application"} %header.navbar.navbar-static-top.navbar-gitlab .navbar-inner .container %div.app_logo %span.separator - = link_to public_root_path, class: "home" do + = link_to root_path, class: "home" do %h1 GITLAB %span.separator - %h1.project_name Public + %h1.project_name Public Area .container .content .prepend-top-20 diff --git a/app/views/public/projects/index.html.haml b/app/views/public/projects/index.html.haml index ba4fd72628f..fceb4817210 100644 --- a/app/views/public/projects/index.html.haml +++ b/app/views/public/projects/index.html.haml @@ -3,7 +3,7 @@ %small Read-Only Access %hr -%ul.well-list +%ul.unstyled - @projects.each do |project| %li.clearfix %h5 From 68bfcd0521020d9f0154ffe767aa1e327e93ca24 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 13 Jan 2013 17:24:29 +0200 Subject: [PATCH 24/32] Add public filter to admin projects --- app/assets/stylesheets/application.scss | 1 + app/assets/stylesheets/sections/admin.scss | 5 ++ app/controllers/admin/projects_controller.rb | 1 + app/controllers/public/projects_controller.rb | 1 + app/views/admin/projects/index.html.haml | 75 +++++++++++-------- app/views/help/index.html.haml | 2 + app/views/help/public_area.html.haml | 16 ++++ app/views/layouts/application.html.haml | 2 +- app/views/public/projects/index.html.haml | 3 + config/routes.rb | 1 + 10 files changed, 73 insertions(+), 34 deletions(-) create mode 100644 app/assets/stylesheets/sections/admin.scss create mode 100644 app/views/help/public_area.html.haml diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 54690e73f81..0e951e7f68c 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -32,6 +32,7 @@ @import "sections/profile.scss"; @import "sections/login.scss"; @import "sections/editor.scss"; +@import "sections/admin.scss"; @import "highlight/white.scss"; @import "highlight/dark.scss"; diff --git a/app/assets/stylesheets/sections/admin.scss b/app/assets/stylesheets/sections/admin.scss new file mode 100644 index 00000000000..18b102d7022 --- /dev/null +++ b/app/assets/stylesheets/sections/admin.scss @@ -0,0 +1,5 @@ +.admin-filter form { + label { width: 110px; } + .controls { margin-left: 130px; } + .form-actions { padding-left: 130px; background: #fff } +} diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb index d5e6f3cdc0e..aa9e2f69a04 100644 --- a/app/controllers/admin/projects_controller.rb +++ b/app/controllers/admin/projects_controller.rb @@ -4,6 +4,7 @@ class Admin::ProjectsController < AdminController def index @projects = Project.scoped @projects = @projects.where(namespace_id: params[:namespace_id]) if params[:namespace_id].present? + @projects = @projects.where(public: true) if params[:public_only].present? @projects = @projects.where(namespace_id: nil) if params[:namespace_id] == Namespace.global_id @projects = @projects.search(params[:name]) if params[:name].present? @projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20) diff --git a/app/controllers/public/projects_controller.rb b/app/controllers/public/projects_controller.rb index 28f46c6f239..4108fe5f363 100644 --- a/app/controllers/public/projects_controller.rb +++ b/app/controllers/public/projects_controller.rb @@ -7,5 +7,6 @@ class Public::ProjectsController < ApplicationController def index @projects = Project.public + @projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20) end end diff --git a/app/views/admin/projects/index.html.haml b/app/views/admin/projects/index.html.haml index 1f5b31eca5f..5a5c63ce6ad 100644 --- a/app/views/admin/projects/index.html.haml +++ b/app/views/admin/projects/index.html.haml @@ -1,38 +1,47 @@ %h3.page_title - Projects (#{Project.count}) + Projects = link_to 'New Project', new_project_path, class: "btn small right" -%br -= form_tag admin_projects_path, method: :get, class: 'form-inline' do - = select_tag :namespace_id, namespaces_options(params[:namespace_id], :all), class: "chosen xlarge", prompt: "Project namespace" - = text_field_tag :name, params[:name], class: "xlarge" - = submit_tag "Search", class: "btn submit primary" -%table - %thead - %tr - %th - Name - %i.icon-sort-down - %th Path - %th Team Members - %th Owner - %th Last Commit - %th Edit - %th.cred Danger Zone! +%hr - - @projects.each do |project| - %tr - %td - = link_to project.name_with_namespace, [:admin, project] - %td - %span.monospace= project.path_with_namespace + ".git" - %td= project.users_projects.count - %td - - if project.owner - = link_to project.owner.name, [:admin, project.owner] +.row + .span4 + .admin-filter + = form_tag admin_projects_path, method: :get, class: 'form-inline' do + .control-group + = label_tag :name, 'Name:', class: 'control-label' + .controls + = text_field_tag :name, params[:name], class: "span2" + + .control-group + = label_tag :namespace_id, 'Namespace:', class: 'control-label' + .controls + = select_tag :namespace_id, namespaces_options(params[:namespace_id], :all), class: "chosen span2", prompt: "Any" + .control-group + = label_tag :public_only, 'Public Only', class: 'control-label' + .controls + = check_box_tag :public_only, 1, params[:public_only] + + .form-actions + = submit_tag "Search", class: "btn submit primary" + = link_to "Reset", admin_projects_path, class: "btn" + .span8 + .ui-box + %h5.title + Projects (#{@projects.total_count}) + %ul.well-list + - @projects.each do |project| + %li + - if project.public + %i.icon-unlock.cred + - else + %i.icon-lock.cgreen + = link_to project.name_with_namespace, [:admin, project] + .right + = link_to 'Edit', edit_admin_project_path(project), id: "edit_#{dom_id(project)}", class: "btn small" + = link_to 'Destroy', [:admin, project], confirm: "REMOVE #{project.name}? Are you sure?", method: :delete, class: "btn small danger" + - if @projects.blank? + %p.nothing_here_message 0 projects matches - else - (deleted) - %td= last_commit(project) - %td= link_to 'Edit', edit_admin_project_path(project), id: "edit_#{dom_id(project)}", class: "btn small" - %td.bgred= link_to 'Destroy', [:admin, project], confirm: "REMOVE #{project.name}? Are you sure?", method: :delete, class: "btn small danger" -= paginate @projects, theme: "admin" + %li.bottom + = paginate @projects, theme: "admin" diff --git a/app/views/help/index.html.haml b/app/views/help/index.html.haml index dc22b672cb7..cadf6c9d6e7 100644 --- a/app/views/help/index.html.haml +++ b/app/views/help/index.html.haml @@ -47,3 +47,5 @@ %li %span= link_to "System Hooks", help_system_hooks_path + %li + %span= link_to "Public Area", help_public_area_path diff --git a/app/views/help/public_area.html.haml b/app/views/help/public_area.html.haml new file mode 100644 index 00000000000..a7a86e92396 --- /dev/null +++ b/app/views/help/public_area.html.haml @@ -0,0 +1,16 @@ +%h3.page_title Public Area +.back_link + = link_to help_path do + ← to index +%hr + +%p + Public area - is part of application with public access. + %br + It used to list all projects with public read-only access. + %br + If you enable public http access to the project - it will appears there + %br + + Follow #{link_to "this link", public_root_path} to visit Public Area + diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index a197de38749..88da5c98c78 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -18,7 +18,7 @@ %span.count= current_user.cared_merge_requests.opened.count = nav_link(path: 'search#show') do = link_to "Search", search_path - = nav_link(path: 'help#index') do + = nav_link(controller: :help) do = link_to "Help", help_path .content= yield diff --git a/app/views/public/projects/index.html.haml b/app/views/public/projects/index.html.haml index fceb4817210..f60a0898821 100644 --- a/app/views/public/projects/index.html.haml +++ b/app/views/public/projects/index.html.haml @@ -12,3 +12,6 @@ .right %span.monospace.tiny git clone #{project.http_url_to_repo} + + += paginate @projects, theme: "admin" diff --git a/config/routes.rb b/config/routes.rb index eeba31d5ae4..ee6dfe6d3e6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -35,6 +35,7 @@ Gitlab::Application.routes.draw do get 'help/markdown' => 'help#markdown' get 'help/ssh' => 'help#ssh' get 'help/raketasks' => 'help#raketasks' + get 'help/public_area' => 'help#public_area' # # Public namespace From 8543313bf5396afe3bdf5851a84c688eacc8156f Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 14 Jan 2013 09:37:29 +0200 Subject: [PATCH 25/32] Few more filters for admin / projects --- app/controllers/admin/projects_controller.rb | 2 ++ app/models/project.rb | 8 ++++++++ app/views/admin/projects/index.html.haml | 16 +++++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb index aa9e2f69a04..64aa6882b45 100644 --- a/app/controllers/admin/projects_controller.rb +++ b/app/controllers/admin/projects_controller.rb @@ -5,6 +5,8 @@ class Admin::ProjectsController < AdminController @projects = Project.scoped @projects = @projects.where(namespace_id: params[:namespace_id]) if params[:namespace_id].present? @projects = @projects.where(public: true) if params[:public_only].present? + @projects = @projects.joins(:events).where('events.action = ?', Event::Pushed) if params[:with_push].present? + @projects = @projects.abandoned if params[:abandoned].present? @projects = @projects.where(namespace_id: nil) if params[:namespace_id] == Namespace.global_id @projects = @projects.search(params[:name]) if params[:name].present? @projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20) diff --git a/app/models/project.rb b/app/models/project.rb index a826e04eac8..4d4a64753f1 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -84,6 +84,14 @@ class Project < ActiveRecord::Base scope :public, where(public: true) class << self + def abandoned + project_ids = Event.select('max(created_at) as latest_date, project_id'). + group('project_id'). + having('latest_date < ?', 6.months.ago).map(&:project_id) + + where(id: project_ids) + end + def active joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC") end diff --git a/app/views/admin/projects/index.html.haml b/app/views/admin/projects/index.html.haml index 5a5c63ce6ad..a3c806bc913 100644 --- a/app/views/admin/projects/index.html.haml +++ b/app/views/admin/projects/index.html.haml @@ -21,6 +21,20 @@ = label_tag :public_only, 'Public Only', class: 'control-label' .controls = check_box_tag :public_only, 1, params[:public_only] + .control-group + = label_tag :with_push, 'Not empty', class: 'control-label' + .controls + = check_box_tag :with_push, 1, params[:with_push] +   + %span.light Projects with push events + .control-group + = label_tag :abandoned, 'Abandoned', class: 'control-label' + .controls + = check_box_tag :abandoned, 1, params[:abandoned] +   + %span.light No activity over 6 month + + .form-actions = submit_tag "Search", class: "btn submit primary" @@ -44,4 +58,4 @@ %p.nothing_here_message 0 projects matches - else %li.bottom - = paginate @projects, theme: "admin" + = paginate @projects, theme: "gitlab" From f716c0a1dd175527e688709cbbd71c121a43586e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 14 Jan 2013 09:44:27 +0200 Subject: [PATCH 26/32] profjects filter with_push to project model --- app/controllers/admin/projects_controller.rb | 2 +- app/models/project.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb index 64aa6882b45..fc78db9e3a7 100644 --- a/app/controllers/admin/projects_controller.rb +++ b/app/controllers/admin/projects_controller.rb @@ -5,7 +5,7 @@ class Admin::ProjectsController < AdminController @projects = Project.scoped @projects = @projects.where(namespace_id: params[:namespace_id]) if params[:namespace_id].present? @projects = @projects.where(public: true) if params[:public_only].present? - @projects = @projects.joins(:events).where('events.action = ?', Event::Pushed) if params[:with_push].present? + @projects = @projects.with_push if params[:with_push].present? @projects = @projects.abandoned if params[:abandoned].present? @projects = @projects.where(namespace_id: nil) if params[:namespace_id] == Namespace.global_id @projects = @projects.search(params[:name]) if params[:name].present? diff --git a/app/models/project.rb b/app/models/project.rb index 4d4a64753f1..ac32352837a 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -92,6 +92,10 @@ class Project < ActiveRecord::Base where(id: project_ids) end + def with_push + includes(:events).where('events.action = ?', Event::Pushed) + end + def active joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC") end From 23e338852c6030e199608517315c5d4fad6b27d8 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 14 Jan 2013 10:09:01 +0200 Subject: [PATCH 27/32] Dont set @project variable in list. Remove a bit of duplication in dash and group --- app/views/dashboard/issues.html.haml | 4 ++-- app/views/dashboard/merge_requests.html.haml | 15 +-------------- app/views/groups/issues.html.haml | 4 ++-- app/views/groups/merge_requests.html.haml | 15 +-------------- app/views/shared/_clone_panel.html.haml | 1 + app/views/shared/_merge_requests.html.haml | 14 ++++++++++++++ 6 files changed, 21 insertions(+), 32 deletions(-) create mode 100644 app/views/shared/_merge_requests.html.haml diff --git a/app/views/dashboard/issues.html.haml b/app/views/dashboard/issues.html.haml index 68e3b3dcaf5..307d0d85ea3 100644 --- a/app/views/dashboard/issues.html.haml +++ b/app/views/dashboard/issues.html.haml @@ -12,9 +12,9 @@ - if @issues.any? - @issues.group_by(&:project).each do |group| %div.ui-box - - @project = group[0] + - project = group[0] %h5.title - = link_to_project @project + = link_to_project project %ul.well-list.issues_table - group[1].each do |issue| = render(partial: 'issues/show', locals: {issue: issue}) diff --git a/app/views/dashboard/merge_requests.html.haml b/app/views/dashboard/merge_requests.html.haml index c5245da731a..0c4d6e0aadf 100644 --- a/app/views/dashboard/merge_requests.html.haml +++ b/app/views/dashboard/merge_requests.html.haml @@ -8,17 +8,4 @@ .span3 = render 'filter', entity: 'merge_request' .span9 - - if @merge_requests.any? - - @merge_requests.group_by(&:project).each do |group| - .ui-box - - @project = group[0] - %h5.title - = link_to_project @project - %ul.well-list - - group[1].each do |merge_request| - = render(partial: 'merge_requests/merge_request', locals: {merge_request: merge_request}) - %hr - = paginate @merge_requests, theme: "gitlab" - - - else - %h3.nothing_here_message Nothing to show here + = render 'shared/merge_requests' diff --git a/app/views/groups/issues.html.haml b/app/views/groups/issues.html.haml index ffca2dc75ea..9e8642f3b2c 100644 --- a/app/views/groups/issues.html.haml +++ b/app/views/groups/issues.html.haml @@ -11,9 +11,9 @@ - if @issues.any? - @issues.group_by(&:project).each do |group| %div.ui-box - - @project = group[0] + - project = group[0] %h5.title - = link_to_project @project + = link_to_project project %ul.well-list.issues_table - group[1].each do |issue| = render(partial: 'issues/show', locals: {issue: issue}) diff --git a/app/views/groups/merge_requests.html.haml b/app/views/groups/merge_requests.html.haml index c5245da731a..0c4d6e0aadf 100644 --- a/app/views/groups/merge_requests.html.haml +++ b/app/views/groups/merge_requests.html.haml @@ -8,17 +8,4 @@ .span3 = render 'filter', entity: 'merge_request' .span9 - - if @merge_requests.any? - - @merge_requests.group_by(&:project).each do |group| - .ui-box - - @project = group[0] - %h5.title - = link_to_project @project - %ul.well-list - - group[1].each do |merge_request| - = render(partial: 'merge_requests/merge_request', locals: {merge_request: merge_request}) - %hr - = paginate @merge_requests, theme: "gitlab" - - - else - %h3.nothing_here_message Nothing to show here + = render 'shared/merge_requests' diff --git a/app/views/shared/_clone_panel.html.haml b/app/views/shared/_clone_panel.html.haml index e283d9b3085..7b5de4a6274 100644 --- a/app/views/shared/_clone_panel.html.haml +++ b/app/views/shared/_clone_panel.html.haml @@ -1,4 +1,5 @@ .input-prepend.project_clone_holder %button{class: "btn active", :"data-clone" => @project.ssh_url_to_repo} SSH %button{class: "btn", :"data-clone" => @project.http_url_to_repo}= Gitlab.config.gitlab.protocol.upcase + = text_field_tag :project_clone, @project.url_to_repo, class: "one_click_select input-xxlarge" diff --git a/app/views/shared/_merge_requests.html.haml b/app/views/shared/_merge_requests.html.haml new file mode 100644 index 00000000000..85391a34316 --- /dev/null +++ b/app/views/shared/_merge_requests.html.haml @@ -0,0 +1,14 @@ +- if @merge_requests.any? + - @merge_requests.group_by(&:project).each do |group| + .ui-box + - project = group[0] + %h5.title + = link_to_project project + %ul.well-list + - group[1].each do |merge_request| + = render(partial: 'merge_requests/merge_request', locals: {merge_request: merge_request}) + %hr + = paginate @merge_requests, theme: "gitlab" + +- else + %h3.nothing_here_message Nothing to show here From eff6d3c12b8f1cd0d3f8f9bab8ceaeba31f915b2 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 14 Jan 2013 13:39:09 +0200 Subject: [PATCH 28/32] CHANGELOG for 4.1 --- CHANGELOG | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index dda12bd11de..5f179f50691 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,24 @@ +v 4.1.0 + - Project public mode (only admin can set now) + - Public area with unauthorized access + - Load dashboard events with ajax + - remember dashboard filter in cookies + - replace resque with sidekiq + - fix routing issues + - cleanup rake tasks + - fix backup/restore + - scss cleanup + - show preview for note images + - improved network-graph + - get rid of app/roles/ + - added new classes Team, Repository + - Reduce amount of gitolite calls + - Ability to add user in all group projects + - remove derecated configs + - replaced Korolev font with open font + - restyled admin/dashboard page + - restyled admin/projects page + v 4.0.0 - Remove project code and path from API. Use id instead - Return valid clonable url to repo for web hook From 80b8921a9a0adb60c7eb8edeaf195d9dc2530cb9 Mon Sep 17 00:00:00 2001 From: Jeremy Slater Date: Mon, 14 Jan 2013 09:46:55 -0500 Subject: [PATCH 29/32] Public HTTP clones and remove auth request for public projects --- lib/gitlab/backend/grack_auth.rb | 74 ++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 23 deletions(-) diff --git a/lib/gitlab/backend/grack_auth.rb b/lib/gitlab/backend/grack_auth.rb index 0defee2b11c..c921ec0d50b 100644 --- a/lib/gitlab/backend/grack_auth.rb +++ b/lib/gitlab/backend/grack_auth.rb @@ -2,31 +2,43 @@ module Grack class Auth < Rack::Auth::Basic attr_accessor :user, :project - def valid? - # Find project by PATH_INFO from env - if m = /^\/([\w\.\/-]+)\.git/.match(@request.path_info).to_a - self.project = Project.find_with_namespace(m.last) - return false unless project - end + def call(env) + @env = env + @request = Rack::Request.new(env) + @auth = Request.new(env) - if @request.get? && project.public - return true - end - - # Authentication with username and password - login, password = @auth.credentials - - self.user = User.find_by_email(login) || User.find_by_username(login) - - return false unless user.try(:valid_password?, password) - - email = user.email - - # Set GL_USER env variable - ENV['GL_USER'] = email # Pass Gitolite update hook ENV['GL_BYPASS_UPDATE_HOOK'] = "true" + # Need this patch due to the rails mount + @env['PATH_INFO'] = @request.path + @env['SCRIPT_NAME'] = "" + + return render_not_found unless project + return unauthorized unless project.public || @auth.provided? + return bad_request if @auth.provided? && !@auth.basic? + + if valid? + if @auth.provided? + @env['REMOTE_USER'] = @auth.username + end + return @app.call(env) + else + unauthorized + end + end + + def valid? + if @auth.provided? + # Authentication with username and password + login, password = @auth.credentials + self.user = User.find_by_email(login) || User.find_by_username(login) + return false unless user.try(:valid_password?, password) + + # Set GL_USER env variable + ENV['GL_USER'] = user.email + end + # Git upload and receive if @request.get? validate_get_request @@ -38,12 +50,12 @@ module Grack end def validate_get_request - can?(user, :download_code, project) + project.public || can?(user, :download_code, project) end def validate_post_request if @request.path_info.end_with?('git-upload-pack') - can?(user, :download_code, project) + project.public || can?(user, :download_code, project) elsif @request.path_info.end_with?('git-receive-pack') action = if project.protected_branch?(current_ref) :push_code_to_protected_branches @@ -72,6 +84,22 @@ module Grack /refs\/heads\/([\w\.-]+)/.match(input).to_a.first end + def project + unless instance_variable_defined? :@project + # Find project by PATH_INFO from env + if m = /^\/([\w\.\/-]+)\.git/.match(@request.path_info).to_a + @project = Project.find_with_namespace(m.last) + end + end + return @project + end + + PLAIN_TYPE = {"Content-Type" => "text/plain"} + + def render_not_found + [404, PLAIN_TYPE, ["Not Found"]] + end + protected def abilities From ba24e242d704cc13e7cb0cb218edd6115abdba1d Mon Sep 17 00:00:00 2001 From: Tim Laszlo Date: Mon, 14 Jan 2013 09:28:33 -0600 Subject: [PATCH 30/32] Update doc/install/installation.md Change "th" to "the" --- doc/install/installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/install/installation.md b/doc/install/installation.md index 718e4cf6419..7fb5e48cdc9 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -19,7 +19,7 @@ following the contribution guide (see `CONTRIBUTING.md`). # Overview -The GitLab installation consists of setting up th following components: +The GitLab installation consists of setting up the following components: 1. Packages / Dependencies 2. Ruby From e98d4780850e8649718f10c2a4d5b3dc7f04b390 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 14 Jan 2013 20:21:04 +0200 Subject: [PATCH 31/32] remove thin from production env. Use unicorn for foreman --- Gemfile | 1 - Gemfile.lock | 6 ------ Procfile | 2 +- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/Gemfile b/Gemfile index 20323f2e3e4..87f45e59c69 100644 --- a/Gemfile +++ b/Gemfile @@ -71,7 +71,6 @@ gem "redcarpet", "~> 2.2.2" gem "github-markup", "~> 0.7.4", require: 'github/markup' # Servers -gem "thin", '~> 1.5.0' gem "unicorn", "~> 4.4.0" # Issue tags diff --git a/Gemfile.lock b/Gemfile.lock index 58d510634e9..666f0d081d7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -144,7 +144,6 @@ GEM colorize (0.5.8) connection_pool (1.0.0) crack (0.3.1) - daemons (1.1.9) devise (2.1.2) bcrypt-ruby (~> 3.0) orm_adapter (~> 0.1) @@ -437,10 +436,6 @@ GEM test_after_commit (0.0.1) therubyracer (0.10.2) libv8 (~> 3.3.10) - thin (1.5.0) - daemons (>= 1.0.9) - eventmachine (>= 0.12.6) - rack (>= 1.0.0) thor (0.16.0) tilt (1.3.3) timers (1.0.2) @@ -547,7 +542,6 @@ DEPENDENCIES stamp test_after_commit therubyracer - thin (~> 1.5.0) uglifier (~> 1.3.0) unicorn (~> 4.4.0) webmock diff --git a/Procfile b/Procfile index d3b3e051e88..21dfade1d8a 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ -web: bundle exec rails s -p $PORT +web: bundle exec unicorn_rails -p $PORT worker: bundle exec sidekiq -q post_receive,mailer,system_hook,common,default From a36926216fc7d3f4d2c36b4637d21a39b8ea7cd9 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 14 Jan 2013 20:55:57 +0200 Subject: [PATCH 32/32] line numbers for blame --- app/assets/stylesheets/sections/tree.scss | 12 +++++++++ app/views/blame/show.html.haml | 31 +++++++++++++++-------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/app/assets/stylesheets/sections/tree.scss b/app/assets/stylesheets/sections/tree.scss index b0d795f4d5a..0ba68e5010c 100644 --- a/app/assets/stylesheets/sections/tree.scss +++ b/app/assets/stylesheets/sections/tree.scss @@ -80,6 +80,18 @@ margin: 0; padding: 0; } + td.blame-commit { + background: #f9f9f9; + min-width: 350px; + } + td.blame-numbers { + pre { + color: #AAA; + white-space: pre; + } + background: #f1f1f1; + border-left: 1px solid #DDD; + } } } diff --git a/app/views/blame/show.html.haml b/app/views/blame/show.html.haml index c5192c53cc3..36d81e6af38 100644 --- a/app/views/blame/show.html.haml +++ b/app/views/blame/show.html.haml @@ -20,16 +20,27 @@ %span.options= render "tree/blob_actions" .file_content.blame %table + - current_line = 1 - @blame.each do |commit, lines| - - commit = Commit.new(commit) - - commit = CommitDecorator.decorate(commit) + - commit = CommitDecorator.decorate(Commit.new(commit)) %tr - %td.author= commit.author_link avatar: true, size: 16 - %td.blame_commit -   - %code= link_to commit.short_id, project_commit_path(@project, commit) - = link_to_gfm truncate(commit.title, length: 30), project_commit_path(@project, commit), class: "row_title" rescue "--broken encoding" + %td.blame-commit + %span.commit + = link_to commit.short_id(8), project_commit_path(@project, commit), class: "commit_short_id" +   + = commit.author_link avatar: true, size: 16 +   + = link_to_gfm truncate(commit.title, length: 20), project_commit_path(@project, commit.id), class: "row_title" + %td.lines.blame-numbers + %pre + - if lines.empty? + = current_line + - current_line += 1 + - else + - lines.each do |line| + = current_line + - current_line += 1 %td.lines - = preserve do - %pre - = lines.join("\n") + %pre + - lines.each do |line| + = line