From 905aa634de8201a00d245a814c9931786b313bcb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=89=E5=A5=BD=E8=89=AF=E5=92=8C?=
 <y.miyoshi@gloops.com>
Date: Thu, 23 May 2013 18:32:37 +0900
Subject: [PATCH 01/12] Fixed "recipe_content" path for 5-2-stable

---
 lib/tasks/gitlab/check.rake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake
index 5e4a74b6260..94fd8b03016 100644
--- a/lib/tasks/gitlab/check.rake
+++ b/lib/tasks/gitlab/check.rake
@@ -144,7 +144,7 @@ namespace :gitlab do
         return
       end
 
-      recipe_content = `curl https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab 2>/dev/null`
+      recipe_content = `curl https://raw.github.com/gitlabhq/gitlabhq/5-2-stable/lib/support/init.d/gitlab 2>/dev/null`
       script_content = File.read(script_path)
 
       if recipe_content == script_content
-- 
GitLab


From 37c6348d332d3eaaf70149be2ccfc62ae4d00eb0 Mon Sep 17 00:00:00 2001
From: Ben Bodenmiller <bbodenmiller@hotmail.com>
Date: Fri, 24 May 2013 16:53:32 -0700
Subject: [PATCH 02/12] update upgrade guide with backup, db specific commands,
 config changes, check, and restore

---
 doc/update/5.1-to-5.2.md | 59 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 2 deletions(-)

diff --git a/doc/update/5.1-to-5.2.md b/doc/update/5.1-to-5.2.md
index 8f2116837b8..3f874555f49 100644
--- a/doc/update/5.1-to-5.2.md
+++ b/doc/update/5.1-to-5.2.md
@@ -1,5 +1,15 @@
 # From 5.1 to 5.2
 
+### 0. Backup
+
+It's useful to make a backup just in case things go south:
+(With MySQL, this may require granting "LOCK TABLES" privileges to the GitLab user on the database version)
+
+```bash
+cd /home/git/gitlab
+sudo -u git -H RAILS_ENV=production bundle exec rake gitlab:backup:create
+```
+
 ### 1. Stop server
 
     sudo service gitlab stop
@@ -20,14 +30,59 @@ sudo -u git -H git fetch
 sudo -u git -H git checkout v1.4.0
 ```
 
-### 4. Install libs, migrations etc
+### 4. Install libs, migrations, etc.
 
 ```bash
 cd /home/git/gitlab
+
+# MySQL
 sudo -u git -H bundle install --without development test postgres --deployment
+
+#PostgreSQL
+sudo -u git -H bundle install --without development test mysql --deployment
+
 sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production
 ```
 
-### 5. Start application
+### 5. Update config files
+
+* Make `/home/git/gitlab/config/gitlab.yml` same as https://github.com/gitlabhq/gitlabhq/blob/5-2-stable/config/gitlab.yml.example but with your settings.
+* Make `/home/git/gitlab/config/puma.rb` same as https://github.com/gitlabhq/gitlabhq/blob/5-2-stable/config/puma.rb.example but with your settings.
+
+### 6. Update Init script
+
+```bash
+sudo rm /etc/init.d/gitlab
+sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlabhq/5-2-stable/lib/support/init.d/gitlab
+sudo chmod +x /etc/init.d/gitlab
+```
+
+### 6. Start application
 
     sudo service gitlab start
+    sudo service nginx restart
+
+### 7. Check application status
+
+Check if GitLab and its environment are configured correctly:
+
+    sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
+
+To make sure you didn't miss anything run a more thorough check with:
+
+    sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
+
+If all items are green, then congratulations upgrade complete!
+
+## Things went south? Revert to previous version (5.1)
+
+### 1. Revert the code to the previous version
+Follow the [`upgrade guide from 5.0 to 5.1`](5.0-to-5.1.md), except for the database migration 
+(The backup is already migrated to the previous version)
+
+### 2. Restore from the backup:
+
+```bash
+cd /home/git/gitlab
+sudo -u git -H RAILS_ENV=production bundle exec rake gitlab:backup:restore
+```
-- 
GitLab


From a9975336e8bf26c64345aa7eb067d9fee52602c3 Mon Sep 17 00:00:00 2001
From: MeiHui FAN <mhfan@ustc.edu>
Date: Thu, 16 May 2013 11:59:26 +0800
Subject: [PATCH 03/12] improve regrex for match(sidekiq) robustness

e.g.: the sidekiq in my Debian box is v2.11.1
---
 lib/tasks/gitlab/check.rake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake
index 94fd8b03016..4c3a607a713 100644
--- a/lib/tasks/gitlab/check.rake
+++ b/lib/tasks/gitlab/check.rake
@@ -588,7 +588,7 @@ namespace :gitlab do
     def check_sidekiq_running
       print "Running? ... "
 
-      if run_and_match("ps aux | grep -i sidekiq", /sidekiq \d\.\d\.\d.+$/)
+      if run_and_match("ps aux | grep -i sidekiq", /sidekiq \d+\.\d+\.\d+.+$/)
         puts "yes".green
       else
         puts "no".red
-- 
GitLab


From b5668bf6008a1b0c0a4dcd25bce9add470e53394 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Salmer=C3=B3n=20Amselem?=
 <daniel.amselem@gmail.com>
Date: Wed, 29 May 2013 01:13:42 +0300
Subject: [PATCH 04/12] Fix typo in smtp_settings.rb.sample

---
 config/initializers/smtp_settings.rb.sample | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/config/initializers/smtp_settings.rb.sample b/config/initializers/smtp_settings.rb.sample
index 333c388f5ff..e62ad0f4b71 100644
--- a/config/initializers/smtp_settings.rb.sample
+++ b/config/initializers/smtp_settings.rb.sample
@@ -1,7 +1,7 @@
 # To enable smtp email delivery for your GitLab instance do next: 
 # 1. Change config/environments/production.rb to use smtp
 #    config.action_mailer.delivery_method = :smtp
-# 2. Rename this file to smpt_settings.rb
+# 2. Rename this file to smtp_settings.rb
 # 3. Edit settings inside this file
 # 4. Restart GitLab instance
 #
-- 
GitLab


From 86874f00c36a543e12ea2b086908e73f92a50d5b Mon Sep 17 00:00:00 2001
From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Date: Tue, 28 May 2013 17:08:21 +0300
Subject: [PATCH 05/12] init.d: Ensure socket is removed before starting
 service

---
 lib/support/init.d/gitlab | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/support/init.d/gitlab b/lib/support/init.d/gitlab
index 4c5499bbf23..f4ca07b3676 100644
--- a/lib/support/init.d/gitlab
+++ b/lib/support/init.d/gitlab
@@ -2,7 +2,7 @@
 
 # GITLAB
 # Maintainer: @randx
-# App Version: 5.1
+# App Version: 5.2
 
 ### BEGIN INIT INFO
 # Provides:          gitlab
@@ -19,6 +19,7 @@ APP_ROOT="/home/git/gitlab"
 APP_USER="git"
 DAEMON_OPTS="-C $APP_ROOT/config/puma.rb"
 PID_PATH="$APP_ROOT/tmp/pids"
+SOCKET_PATH="$APP_ROOT/tmp/sockets"
 WEB_SERVER_PID="$PID_PATH/puma.pid"
 SIDEKIQ_PID="$PID_PATH/sidekiq.pid"
 STOP_SIDEKIQ="RAILS_ENV=production bundle exec rake sidekiq:stop"
@@ -50,6 +51,7 @@ start() {
     exit 1
   else
     if [ `whoami` = root ]; then
+      execute "rm $SOCKET_PATH/gitlab.socket"
       execute "RAILS_ENV=production bundle exec puma $DAEMON_OPTS"
       execute "mkdir -p $PID_PATH && $START_SIDEKIQ  > /dev/null  2>&1 &"
       echo "$DESC started"
-- 
GitLab


From 6470cfee3e24ba9455191a8ea500b46c150f6ecf Mon Sep 17 00:00:00 2001
From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Date: Wed, 29 May 2013 21:41:12 +0300
Subject: [PATCH 06/12] Fix dashboard event filter when navigate via turbolinks

---
 app/assets/javascripts/dashboard.js.coffee | 2 +-
 app/assets/javascripts/pager.js.coffee     | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/app/assets/javascripts/dashboard.js.coffee b/app/assets/javascripts/dashboard.js.coffee
index 9beca261467..c2fb95ca635 100644
--- a/app/assets/javascripts/dashboard.js.coffee
+++ b/app/assets/javascripts/dashboard.js.coffee
@@ -27,7 +27,7 @@ class Dashboard
     else
       event_filters.splice index, 1
 
-    $.cookie "event_filter", event_filters.join(",")
+    $.cookie "event_filter", event_filters.join(","), { path: '/' }
 
   initSidebarTab: ->
     key = "dashboard_sidebar_filter"
diff --git a/app/assets/javascripts/pager.js.coffee b/app/assets/javascripts/pager.js.coffee
index 5f606acdf9c..5bd11d273a7 100644
--- a/app/assets/javascripts/pager.js.coffee
+++ b/app/assets/javascripts/pager.js.coffee
@@ -30,6 +30,7 @@
       @disable = true
 
   initLoadMore: ->
+    $(document).unbind('scroll')
     $(document).endlessScroll
       bottomPixels: 400
       fireDelay: 1000
-- 
GitLab


From fe86dcfb6617dcdbfe19041b973a946cf93643dd Mon Sep 17 00:00:00 2001
From: Sato Hiroyuki <sathiroyuki@gmail.com>
Date: Sun, 2 Jun 2013 07:05:48 +0000
Subject: [PATCH 07/12] Fix postgres error when displaying network graph.

fix #4149
---
 app/models/network/graph.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/models/network/graph.rb b/app/models/network/graph.rb
index ffec4712e45..da815a85924 100644
--- a/app/models/network/graph.rb
+++ b/app/models/network/graph.rb
@@ -25,7 +25,7 @@ module Network
     def collect_notes
       h = Hash.new(0)
       @project.notes.where('noteable_type = ?' ,"Commit").group('notes.commit_id').select('notes.commit_id, count(notes.id) as note_count').each do |item|
-        h[item["commit_id"]] = item["note_count"]
+        h[item.commit_id] = item.note_count.to_i
       end
       h
     end
-- 
GitLab


From e414ba2f8de10ca0d56f3e1916896018e7611c83 Mon Sep 17 00:00:00 2001
From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Date: Tue, 4 Jun 2013 16:35:08 +0300
Subject: [PATCH 08/12] Do not render project events since we render them again
 via ajax request

---
 app/views/projects/show.html.haml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml
index b2e9fd8431a..f72ef0a99ae 100644
--- a/app/views/projects/show.html.haml
+++ b/app/views/projects/show.html.haml
@@ -3,7 +3,7 @@
 .row
   .span9
     = render "events/event_last_push", event: @last_push
-    .content_list= render @events
+    .content_list
     .loading.hide
   .span3
     .light-well
-- 
GitLab


From f82ec5b9f276424fe3f26c8b3bbf6b070e00243f Mon Sep 17 00:00:00 2001
From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Date: Mon, 10 Jun 2013 12:36:22 +0300
Subject: [PATCH 09/12] Update gitlab-grack. Fixes issue with --depth option

---
 Gemfile      | 2 +-
 Gemfile.lock | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Gemfile b/Gemfile
index 2bc55bfa1cd..633fb8be1ac 100644
--- a/Gemfile
+++ b/Gemfile
@@ -26,7 +26,7 @@ gem 'omniauth-github'
 gem 'gitlab_git', '~> 1.2.1'
 
 # Ruby/Rack Git Smart-HTTP Server Handler
-gem 'gitlab-grack', '~> 1.0.0', require: 'grack'
+gem 'gitlab-grack', '~> 1.0.1', require: 'grack'
 
 # LDAP Auth
 gem 'gitlab_omniauth-ldap', '1.0.2', require: "omniauth-ldap"
diff --git a/Gemfile.lock b/Gemfile.lock
index 93798439d8c..53f2a2d308f 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -158,7 +158,7 @@ GEM
       pygments.rb (~> 0.4.2)
       sanitize (~> 2.0.3)
       stringex (~> 1.5.1)
-    gitlab-grack (1.0.0)
+    gitlab-grack (1.0.1)
       rack (~> 1.4.1)
     gitlab-grit (2.5.1)
       charlock_holmes (~> 0.6.9)
@@ -510,7 +510,7 @@ DEPENDENCIES
   github-linguist
   github-markup (~> 0.7.4)
   gitlab-gollum-lib (~> 1.0.0)
-  gitlab-grack (~> 1.0.0)
+  gitlab-grack (~> 1.0.1)
   gitlab-pygments.rb (~> 0.3.2)
   gitlab_git (~> 1.2.1)
   gitlab_meta (= 5.0)
-- 
GitLab


From f96827c4f017d5d8114d488d352695ed03c88c0a Mon Sep 17 00:00:00 2001
From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Date: Fri, 7 Jun 2013 17:18:11 +0300
Subject: [PATCH 10/12] Fix dashboard lost if comment on commit

---
 app/helpers/events_helper.rb           | 8 ++++++++
 app/views/events/event/_note.html.haml | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb
index 7155036eeed..80dcc127e7e 100644
--- a/app/helpers/events_helper.rb
+++ b/app/helpers/events_helper.rb
@@ -83,4 +83,12 @@ module EventsHelper
       render "events/event_push", event: event
     end
   end
+
+  def event_note_target_path(event)
+    if event.note? && event.note_commit?
+      project_commit_path(event.project, event.note_target)
+    else
+      url_for([event.project, event.note_target])
+    end
+  end
 end
diff --git a/app/views/events/event/_note.html.haml b/app/views/events/event/_note.html.haml
index 8bcfa95ff62..70289b65663 100644
--- a/app/views/events/event/_note.html.haml
+++ b/app/views/events/event/_note.html.haml
@@ -6,7 +6,7 @@
       = event.note_target_type
       = link_to event.note_short_commit_id, project_commit_path(event.project, event.note_commit_id), class: "commit_short_id"
     - else
-      = link_to [event.project, event.note_target] do
+      = link_to event_note_target_path(event) do
         %strong
           #{event.note_target_type} ##{truncate event.note_target_id}
 
-- 
GitLab


From 26ed59f1a53416b2e157cfbf7852663cf0969f5b Mon Sep 17 00:00:00 2001
From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Date: Mon, 10 Jun 2013 18:16:09 +0300
Subject: [PATCH 11/12] v5.2.1

---
 CHANGELOG | 8 ++++++++
 VERSION   | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG b/CHANGELOG
index f21a9e8a943..139049774c7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,11 @@
+v 5.2.1
+  - Fix dashboard lost if comment on commit
+  - Update gitlab-grack. Fixes issue with --depth option
+  - Fix project events duplicate on project page
+  - Fix postgres error when displaying network graph.
+  - Fix dashboard event filter when navigate via turbolinks
+  - init.d: Ensure socket is removed before starting service
+
 v 5.2.0
   - Turbolinks
   - Git over http with ldap credentials
diff --git a/VERSION b/VERSION
index 91ff57278e3..26d99a283f2 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-5.2.0
+5.2.1
-- 
GitLab


From 6a868a4c2bfc7925cf155b6a09c5090b0c5b9aec Mon Sep 17 00:00:00 2001
From: Sytse Sijbrandij <sytse@dosire.com>
Date: Sun, 9 Jun 2013 21:30:20 +0200
Subject: [PATCH 12/12] Fix pygment lexer 500 errors when an alias is used
 instead of a name.

---
 lib/redcarpet/render/gitlab_html.rb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/redcarpet/render/gitlab_html.rb b/lib/redcarpet/render/gitlab_html.rb
index 4f2c86e2d41..318adbf1894 100644
--- a/lib/redcarpet/render/gitlab_html.rb
+++ b/lib/redcarpet/render/gitlab_html.rb
@@ -11,7 +11,8 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
 
   def block_code(code, language)
     options = { options: {encoding: 'utf-8'} }
-    options.merge!(lexer: language.downcase) if Pygments::Lexer.find(language)
+    lexer = Pygments::Lexer.find(language) # language can be an alias
+    options.merge!(lexer: lexer.name.downcase) if lexer # downcase is required
 
     # New lines are placed to fix an rendering issue
     # with code wrapped inside <h1> tag for next case:
-- 
GitLab