summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dzaporozhets@gitlab.com>2015-03-20 22:42:09 +0000
committerDmitriy Zaporozhets <dzaporozhets@gitlab.com>2015-03-20 22:42:09 +0000
commit1a150e144087cdd2d936823401a6d24baa31ad86 (patch)
tree9863c5bea05e24e32bd37c695303a612cd607df3
parentc7c029f40536bce18f7968b0649c10e4ceecdd98 (diff)
parent3d7eb9d9151773e01c34cf53dfc91e6bfc2207b3 (diff)
downloadgitlab-ci-1a150e144087cdd2d936823401a6d24baa31ad86.tar.gz
Merge branch 'commit_belongs_to_ref' into 'master'
Commit url with ref FIxes #162 !!! Should be merged simultaneously with https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/1638 See merge request !129
-rw-r--r--CHANGELOG1
-rw-r--r--app/controllers/builds_controller.rb2
-rw-r--r--app/controllers/commits_controller.rb2
-rw-r--r--app/helpers/commits_helper.rb2
-rw-r--r--app/models/project_services/slack_message.rb2
-rw-r--r--app/services/create_commit_service.rb2
-rw-r--r--app/views/builds/show.html.haml2
-rw-r--r--app/views/commits/_commit.html.haml2
-rw-r--r--config/routes.rb9
-rw-r--r--spec/features/commits_spec.rb2
-rw-r--r--spec/requests/commits_spec.rb4
11 files changed, 17 insertions, 13 deletions
diff --git a/CHANGELOG b/CHANGELOG
index cb8a676..beba00e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -13,6 +13,7 @@ v7.9.0
- Allow to pause runners - when paused runner will not receive any new build (Kamil TrzciƄski)
- Add brakeman (security scanner for Ruby on Rails)
- Changed a color of the canceled builds
+ - Fix of show the same commits in different branches
v7.8.2
- Fix the broken build failed email
diff --git a/app/controllers/builds_controller.rb b/app/controllers/builds_controller.rb
index c8cb69f..bb485c0 100644
--- a/app/controllers/builds_controller.rb
+++ b/app/controllers/builds_controller.rb
@@ -14,7 +14,7 @@ class BuildsController < ApplicationController
if commit
# Redirect to commit page
- redirect_to project_commit_path(commit.project, commit)
+ redirect_to project_ref_commit_path(@project, @build.commit.ref, @build.commit.sha)
return
end
end
diff --git a/app/controllers/commits_controller.rb b/app/controllers/commits_controller.rb
index 929841e..e541ac0 100644
--- a/app/controllers/commits_controller.rb
+++ b/app/controllers/commits_controller.rb
@@ -19,6 +19,6 @@ class CommitsController < ApplicationController
end
def commit
- @commit ||= project.commits.find_by(sha: params[:id])
+ @commit ||= Project.find(params[:project_id]).commits.find_by_sha_and_ref!(params[:id], params[:ref_id])
end
end
diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb
index c0a8f31..b94cfaf 100644
--- a/app/helpers/commits_helper.rb
+++ b/app/helpers/commits_helper.rb
@@ -13,6 +13,6 @@ module CommitsHelper
end
def commit_link(commit)
- link_to(commit.short_sha, project_commit_path(commit.project, commit))
+ link_to(commit.short_sha, project_ref_commit_path(commit.project, commit.ref, commit.sha))
end
end
diff --git a/app/models/project_services/slack_message.rb b/app/models/project_services/slack_message.rb
index a37041a..8d8bfcf 100644
--- a/app/models/project_services/slack_message.rb
+++ b/app/models/project_services/slack_message.rb
@@ -44,7 +44,7 @@ class SlackMessage
def attachment_message
out = "<#{RoutesHelper.project_url(project)}|#{project_name}>: "
if commit.matrix?
- out << "Commit <#{RoutesHelper.project_commit_url(project, commit)}|\##{commit.id}> "
+ out << "Commit <#{RoutesHelper.project_ref_commit_url(project, commit.ref, commit.sha)}|\##{commit.id}> "
else
build = commit.builds_without_retry.first
out << "Build <#{RoutesHelper.project_build_url(project, build)}|\##{build.id}> "
diff --git a/app/services/create_commit_service.rb b/app/services/create_commit_service.rb
index b7a5903..e2e7053 100644
--- a/app/services/create_commit_service.rb
+++ b/app/services/create_commit_service.rb
@@ -19,7 +19,7 @@ class CreateCommitService
return false
end
- commit = project.commits.find_by(sha: sha)
+ commit = project.commits.find_by_sha_and_ref(sha, ref)
# Create commit if not exists yet
unless commit
diff --git a/app/views/builds/show.html.haml b/app/views/builds/show.html.haml
index 484aa35..2a28d8d 100644
--- a/app/views/builds/show.html.haml
+++ b/app/views/builds/show.html.haml
@@ -9,7 +9,7 @@
Edit Job
%p
- = link_to project_commit_path(@project, @build.commit) do
+ = link_to project_ref_commit_path(@project, @commit.ref, @commit.sha) do
&larr; Back to project commit
%hr
#up-build-trace
diff --git a/app/views/commits/_commit.html.haml b/app/views/commits/_commit.html.haml
index 0284771..54acf08 100644
--- a/app/views/commits/_commit.html.haml
+++ b/app/views/commits/_commit.html.haml
@@ -3,7 +3,7 @@
= commit.status
%td.build-link
- = link_to project_commit_path(commit.project, commit) do
+ = link_to project_ref_commit_path(commit.project, commit.ref, commit.sha) do
%strong #{commit.short_sha}
%td.build-message
diff --git a/config/routes.rb b/config/routes.rb
index f666482..1ee64ba 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -28,9 +28,12 @@ Rails.application.routes.draw do
end
resource :charts, only: [:show]
- resources :commits, only: [:show] do
- member do
- get :status
+
+ resources :refs, constraints: { ref_id: /.*/ }, only: [] do
+ resources :commits, only: [:show] do
+ member do
+ get :status
+ end
end
end
diff --git a/spec/features/commits_spec.rb b/spec/features/commits_spec.rb
index ac014d3..01d5eef 100644
--- a/spec/features/commits_spec.rb
+++ b/spec/features/commits_spec.rb
@@ -11,7 +11,7 @@ describe "Commits" do
describe "GET /:project/commits/:sha" do
before do
- visit project_commit_path(@project, @commit)
+ visit project_ref_commit_path(@project, @commit.ref, @commit.sha)
end
it { page.should have_content @commit.sha[0..7] }
diff --git a/spec/requests/commits_spec.rb b/spec/requests/commits_spec.rb
index 5c894ea..e9d8366 100644
--- a/spec/requests/commits_spec.rb
+++ b/spec/requests/commits_spec.rb
@@ -6,9 +6,9 @@ describe "Commits" do
@commit = FactoryGirl.create :commit, project: @project
end
- describe "GET /:project/commits/:id/status.json" do
+ describe "GET /:project/refs/:ref_name/commits/:id/status.json" do
before do
- get status_project_commit_path(@project, @commit), format: :json
+ get status_project_ref_commit_path(@project, @commit.ref, @commit.sha), format: :json
end
it { response.status.should == 200 }