Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
8ed7ac9d
Commit
8ed7ac9d
authored
Apr 21, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use project.commit convenience method.
parent
84a15902
Changes
30
Show whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
44 additions
and
44 deletions
+44
-44
app/controllers/projects/commit_controller.rb
app/controllers/projects/commit_controller.rb
+1
-1
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+1
-1
app/models/note.rb
app/models/note.rb
+2
-2
app/models/project.rb
app/models/project.rb
+1
-1
app/models/protected_branch.rb
app/models/protected_branch.rb
+1
-1
app/services/create_tag_service.rb
app/services/create_tag_service.rb
+1
-1
app/services/git_tag_push_service.rb
app/services/git_tag_push_service.rb
+1
-1
app/services/projects/participants_service.rb
app/services/projects/participants_service.rb
+1
-1
lib/api/commits.rb
lib/api/commits.rb
+4
-4
lib/api/files.rb
lib/api/files.rb
+1
-1
lib/api/repositories.rb
lib/api/repositories.rb
+1
-1
lib/gitlab/identifier.rb
lib/gitlab/identifier.rb
+1
-1
lib/gitlab/markdown/commit_range_reference_filter.rb
lib/gitlab/markdown/commit_range_reference_filter.rb
+1
-1
lib/gitlab/markdown/commit_reference_filter.rb
lib/gitlab/markdown/commit_reference_filter.rb
+1
-1
lib/gitlab/note_data_builder.rb
lib/gitlab/note_data_builder.rb
+1
-1
spec/controllers/commit_controller_spec.rb
spec/controllers/commit_controller_spec.rb
+1
-1
spec/features/gitlab_flavored_markdown_spec.rb
spec/features/gitlab_flavored_markdown_spec.rb
+1
-1
spec/helpers/diff_helper_spec.rb
spec/helpers/diff_helper_spec.rb
+1
-1
spec/helpers/gitlab_markdown_helper_spec.rb
spec/helpers/gitlab_markdown_helper_spec.rb
+1
-1
spec/helpers/tree_helper_spec.rb
spec/helpers/tree_helper_spec.rb
+1
-1
spec/lib/gitlab/diff/file_spec.rb
spec/lib/gitlab/diff/file_spec.rb
+1
-1
spec/lib/gitlab/diff/parser_spec.rb
spec/lib/gitlab/diff/parser_spec.rb
+1
-1
spec/lib/gitlab/markdown/commit_range_reference_filter_spec.rb
...lib/gitlab/markdown/commit_range_reference_filter_spec.rb
+4
-4
spec/lib/gitlab/markdown/commit_reference_filter_spec.rb
spec/lib/gitlab/markdown/commit_reference_filter_spec.rb
+2
-2
spec/lib/gitlab/reference_extractor_spec.rb
spec/lib/gitlab/reference_extractor_spec.rb
+3
-3
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+1
-1
spec/models/commit_spec.rb
spec/models/commit_spec.rb
+1
-1
spec/models/note_spec.rb
spec/models/note_spec.rb
+3
-3
spec/services/git_push_service_spec.rb
spec/services/git_push_service_spec.rb
+3
-3
spec/services/git_tag_push_service_spec.rb
spec/services/git_tag_push_service_spec.rb
+1
-1
No files found.
app/controllers/projects/commit_controller.rb
View file @
8ed7ac9d
...
...
@@ -36,6 +36,6 @@ class Projects::CommitController < Projects::ApplicationController
end
def
commit
@commit
||=
@project
.
repository
.
commit
(
params
[
:id
])
@commit
||=
@project
.
commit
(
params
[
:id
])
end
end
app/controllers/projects/merge_requests_controller.rb
View file @
8ed7ac9d
...
...
@@ -146,7 +146,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def
branch_to
@target_project
=
selected_target_project
@commit
=
@target_project
.
repository
.
commit
(
params
[
:ref
])
if
params
[
:ref
].
present?
@commit
=
@target_project
.
commit
(
params
[
:ref
])
if
params
[
:ref
].
present?
end
def
update_branches
...
...
app/models/note.rb
View file @
8ed7ac9d
...
...
@@ -290,7 +290,7 @@ class Note < ActiveRecord::Base
# +mentioner+.
def
noteable_project_id
(
noteable
,
mentioning_project
)
if
noteable
.
is_a?
(
Commit
)
if
mentioning_project
.
repository
.
commit
(
noteable
.
id
)
if
mentioning_project
.
commit
(
noteable
.
id
)
# The noteable commit belongs to the mentioner's project
mentioning_project
.
id
else
...
...
@@ -512,7 +512,7 @@ class Note < ActiveRecord::Base
# override to return commits, which are not active record
def
noteable
if
for_commit?
project
.
repository
.
commit
(
commit_id
)
project
.
commit
(
commit_id
)
else
super
end
...
...
app/models/project.rb
View file @
8ed7ac9d
...
...
@@ -257,7 +257,7 @@ class Project < ActiveRecord::Base
@repository
||=
Repository
.
new
(
path_with_namespace
,
nil
,
self
)
end
def
commit
(
id
)
def
commit
(
id
=
'HEAD'
)
repository
.
commit
(
id
)
end
...
...
app/models/protected_branch.rb
View file @
8ed7ac9d
...
...
@@ -18,6 +18,6 @@ class ProtectedBranch < ActiveRecord::Base
validates
:project
,
presence:
true
def
commit
project
.
repository
.
commit
(
self
.
name
)
project
.
commit
(
self
.
name
)
end
end
app/services/create_tag_service.rb
View file @
8ed7ac9d
...
...
@@ -38,7 +38,7 @@ class CreateTagService < BaseService
end
def
create_push_data
(
project
,
user
,
tag
)
commits
=
[
project
.
repository
.
commit
(
tag
.
target
)].
compact
commits
=
[
project
.
commit
(
tag
.
target
)].
compact
Gitlab
::
PushDataBuilder
.
build
(
project
,
user
,
Gitlab
::
Git
::
BLANK_SHA
,
tag
.
target
,
"
#{
Gitlab
::
Git
::
TAG_REF_PREFIX
}#{
tag
.
name
}
"
,
commits
,
tag
.
message
)
end
...
...
app/services/git_tag_push_service.rb
View file @
8ed7ac9d
...
...
@@ -25,7 +25,7 @@ class GitTagPushService
tag_name
=
Gitlab
::
Git
.
ref_name
(
ref
)
tag
=
project
.
repository
.
find_tag
(
tag_name
)
if
tag
&&
tag
.
target
==
newrev
commit
=
project
.
repository
.
commit
(
tag
.
target
)
commit
=
project
.
commit
(
tag
.
target
)
commits
=
[
commit
].
compact
message
=
tag
.
message
end
...
...
app/services/projects/participants_service.rb
View file @
8ed7ac9d
...
...
@@ -22,7 +22,7 @@ module Projects
merge_request
=
project
.
merge_requests
.
find_by_iid
(
id
)
merge_request
.
participants
(
current_user
)
if
merge_request
when
"Commit"
commit
=
project
.
repository
.
commit
(
id
)
commit
=
project
.
commit
(
id
)
commit
.
participants
(
project
,
current_user
)
if
commit
end
...
...
lib/api/commits.rb
View file @
8ed7ac9d
...
...
@@ -32,7 +32,7 @@ module API
# GET /projects/:id/repository/commits/:sha
get
":id/repository/commits/:sha"
do
sha
=
params
[
:sha
]
commit
=
user_project
.
repository
.
commit
(
sha
)
commit
=
user_project
.
commit
(
sha
)
not_found!
"Commit"
unless
commit
present
commit
,
with:
Entities
::
RepoCommitDetail
end
...
...
@@ -46,7 +46,7 @@ module API
# GET /projects/:id/repository/commits/:sha/diff
get
":id/repository/commits/:sha/diff"
do
sha
=
params
[
:sha
]
commit
=
user_project
.
repository
.
commit
(
sha
)
commit
=
user_project
.
commit
(
sha
)
not_found!
"Commit"
unless
commit
commit
.
diffs
end
...
...
@@ -60,7 +60,7 @@ module API
# GET /projects/:id/repository/commits/:sha/comments
get
':id/repository/commits/:sha/comments'
do
sha
=
params
[
:sha
]
commit
=
user_project
.
repository
.
commit
(
sha
)
commit
=
user_project
.
commit
(
sha
)
not_found!
'Commit'
unless
commit
notes
=
Note
.
where
(
commit_id:
commit
.
id
)
present
paginate
(
notes
),
with:
Entities
::
CommitNote
...
...
@@ -81,7 +81,7 @@ module API
required_attributes!
[
:note
]
sha
=
params
[
:sha
]
commit
=
user_project
.
repository
.
commit
(
sha
)
commit
=
user_project
.
commit
(
sha
)
not_found!
'Commit'
unless
commit
opts
=
{
note:
params
[
:note
],
...
...
lib/api/files.rb
View file @
8ed7ac9d
...
...
@@ -34,7 +34,7 @@ module API
ref
=
attrs
.
delete
(
:ref
)
file_path
=
attrs
.
delete
(
:file_path
)
commit
=
user_project
.
repository
.
commit
(
ref
)
commit
=
user_project
.
commit
(
ref
)
not_found!
'Commit'
unless
commit
blob
=
user_project
.
repository
.
blob_at
(
commit
.
sha
,
file_path
)
...
...
lib/api/repositories.rb
View file @
8ed7ac9d
...
...
@@ -62,7 +62,7 @@ module API
ref
=
params
[
:ref_name
]
||
user_project
.
try
(
:default_branch
)
||
'master'
path
=
params
[
:path
]
||
nil
commit
=
user_project
.
repository
.
commit
(
ref
)
commit
=
user_project
.
commit
(
ref
)
not_found!
(
'Tree'
)
unless
commit
tree
=
user_project
.
repository
.
tree
(
commit
.
id
,
path
)
...
...
lib/gitlab/identifier.rb
View file @
8ed7ac9d
...
...
@@ -5,7 +5,7 @@ module Gitlab
def
identify
(
identifier
,
project
,
newrev
)
if
identifier
.
blank?
# Local push from gitlab
email
=
project
.
repository
.
commit
(
newrev
).
author_email
rescue
nil
email
=
project
.
commit
(
newrev
).
author_email
rescue
nil
User
.
find_by
(
email:
email
)
if
email
elsif
identifier
=~
/\Auser-\d+\Z/
...
...
lib/gitlab/markdown/commit_range_reference_filter.rb
View file @
8ed7ac9d
...
...
@@ -84,7 +84,7 @@ module Gitlab
def
commit
(
id
)
unless
@commit_map
[
id
]
@commit_map
[
id
]
=
project
.
repository
.
commit
(
id
)
@commit_map
[
id
]
=
project
.
commit
(
id
)
end
@commit_map
[
id
]
...
...
lib/gitlab/markdown/commit_reference_filter.rb
View file @
8ed7ac9d
...
...
@@ -66,7 +66,7 @@ module Gitlab
def
commit_from_ref
(
project
,
commit_ref
)
if
project
&&
project
.
valid_repo?
project
.
repository
.
commit
(
commit_ref
)
project
.
commit
(
commit_ref
)
end
end
...
...
lib/gitlab/note_data_builder.rb
View file @
8ed7ac9d
...
...
@@ -69,7 +69,7 @@ module Gitlab
def
build_data_for_commit
(
project
,
user
,
note
)
# commit_id is the SHA hash
commit
=
project
.
repository
.
commit
(
note
.
commit_id
)
commit
=
project
.
commit
(
note
.
commit_id
)
commit
.
hook_attrs
(
project
)
end
end
...
...
spec/controllers/commit_controller_spec.rb
View file @
8ed7ac9d
...
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
Projects
::
CommitController
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:commit
)
{
project
.
repository
.
commit
(
"master"
)
}
let
(
:commit
)
{
project
.
commit
(
"master"
)
}
before
do
sign_in
(
user
)
...
...
spec/features/gitlab_flavored_markdown_spec.rb
View file @
8ed7ac9d
...
...
@@ -14,7 +14,7 @@ describe "GitLab Flavored Markdown", feature: true do
Commit
.
any_instance
.
stub
(
title:
"fix #
#{
issue
.
iid
}
\n\n
ask @
#{
fred
.
username
}
for details"
)
end
let
(
:commit
)
{
project
.
repository
.
commit
}
let
(
:commit
)
{
project
.
commit
}
before
do
login_as
:user
...
...
spec/helpers/diff_helper_spec.rb
View file @
8ed7ac9d
...
...
@@ -4,7 +4,7 @@ describe DiffHelper do
include
RepoHelpers
let
(
:project
)
{
create
(
:project
)
}
let
(
:commit
)
{
project
.
repository
.
commit
(
sample_commit
.
id
)
}
let
(
:commit
)
{
project
.
commit
(
sample_commit
.
id
)
}
let
(
:diff
)
{
commit
.
diffs
.
first
}
let
(
:diff_file
)
{
Gitlab
::
Diff
::
File
.
new
(
diff
)
}
...
...
spec/helpers/gitlab_markdown_helper_spec.rb
View file @
8ed7ac9d
...
...
@@ -6,7 +6,7 @@ describe GitlabMarkdownHelper do
let!
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
,
username:
'gfm'
)
}
let
(
:commit
)
{
project
.
repository
.
commit
}
let
(
:commit
)
{
project
.
commit
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
}
let
(
:snippet
)
{
create
(
:project_snippet
,
project:
project
)
}
...
...
spec/helpers/tree_helper_spec.rb
View file @
8ed7ac9d
...
...
@@ -6,7 +6,7 @@ describe TreeHelper do
before
{
@repository
=
project
.
repository
@commit
=
project
.
repository
.
commit
(
"e56497bb"
)
@commit
=
project
.
commit
(
"e56497bb"
)
}
context
"on a directory containing more than one file/directory"
do
...
...
spec/lib/gitlab/diff/file_spec.rb
View file @
8ed7ac9d
...
...
@@ -4,7 +4,7 @@ describe Gitlab::Diff::File do
include
RepoHelpers
let
(
:project
)
{
create
(
:project
)
}
let
(
:commit
)
{
project
.
repository
.
commit
(
sample_commit
.
id
)
}
let
(
:commit
)
{
project
.
commit
(
sample_commit
.
id
)
}
let
(
:diff
)
{
commit
.
diffs
.
first
}
let
(
:diff_file
)
{
Gitlab
::
Diff
::
File
.
new
(
diff
)
}
...
...
spec/lib/gitlab/diff/parser_spec.rb
View file @
8ed7ac9d
...
...
@@ -4,7 +4,7 @@ describe Gitlab::Diff::Parser do
include
RepoHelpers
let
(
:project
)
{
create
(
:project
)
}
let
(
:commit
)
{
project
.
repository
.
commit
(
sample_commit
.
id
)
}
let
(
:commit
)
{
project
.
commit
(
sample_commit
.
id
)
}
let
(
:diff
)
{
commit
.
diffs
.
first
}
let
(
:parser
)
{
Gitlab
::
Diff
::
Parser
.
new
}
...
...
spec/lib/gitlab/markdown/commit_range_reference_filter_spec.rb
View file @
8ed7ac9d
...
...
@@ -5,8 +5,8 @@ module Gitlab::Markdown
include
ReferenceFilterSpecHelper
let
(
:project
)
{
create
(
:project
)
}
let
(
:commit1
)
{
project
.
repository
.
commit
}
let
(
:commit2
)
{
project
.
repository
.
commit
(
"HEAD~2"
)
}
let
(
:commit1
)
{
project
.
commit
}
let
(
:commit2
)
{
project
.
commit
(
"HEAD~2"
)
}
it
'requires project context'
do
expect
{
described_class
.
call
(
'Commit Range 1c002d..d200c1'
,
{})
}.
...
...
@@ -86,8 +86,8 @@ module Gitlab::Markdown
context
'cross-project reference'
do
let
(
:namespace
)
{
create
(
:namespace
,
name:
'cross-reference'
)
}
let
(
:project2
)
{
create
(
:project
,
namespace:
namespace
)
}
let
(
:commit1
)
{
project
.
repository
.
commit
}
let
(
:commit2
)
{
project
.
repository
.
commit
(
"HEAD~2"
)
}
let
(
:commit1
)
{
project
.
commit
}
let
(
:commit2
)
{
project
.
commit
(
"HEAD~2"
)
}
let
(
:reference
)
{
"
#{
project2
.
path_with_namespace
}
@
#{
commit1
.
id
}
...
#{
commit2
.
id
}
"
}
context
'when user can access reference'
do
...
...
spec/lib/gitlab/markdown/commit_reference_filter_spec.rb
View file @
8ed7ac9d
...
...
@@ -5,7 +5,7 @@ module Gitlab::Markdown
include
ReferenceFilterSpecHelper
let
(
:project
)
{
create
(
:project
)
}
let
(
:commit
)
{
project
.
repository
.
commit
}
let
(
:commit
)
{
project
.
commit
}
it
'requires project context'
do
expect
{
described_class
.
call
(
'Commit 1c002d'
,
{})
}.
...
...
@@ -80,7 +80,7 @@ module Gitlab::Markdown
context
'cross-project reference'
do
let
(
:namespace
)
{
create
(
:namespace
,
name:
'cross-reference'
)
}
let
(
:project2
)
{
create
(
:project
,
namespace:
namespace
)
}
let
(
:commit
)
{
project
.
repository
.
commit
}
let
(
:commit
)
{
project
.
commit
}
let
(
:reference
)
{
"
#{
project2
.
path_with_namespace
}
@
#{
commit
.
id
}
"
}
context
'when user can access reference'
do
...
...
spec/lib/gitlab/reference_extractor_spec.rb
View file @
8ed7ac9d
...
...
@@ -125,7 +125,7 @@ describe Gitlab::ReferenceExtractor do
end
it
'accesses valid commits'
do
commit
=
project
.
repository
.
commit
(
'master'
)
commit
=
project
.
commit
(
'master'
)
subject
.
analyze
(
"this references commits
#{
commit
.
sha
[
0
..
6
]
}
and 012345"
)
extracted
=
subject
.
commits
...
...
@@ -135,8 +135,8 @@ describe Gitlab::ReferenceExtractor do
end
it
'accesses valid commit ranges'
do
commit
=
project
.
repository
.
commit
(
'master'
)
earlier_commit
=
project
.
repository
.
commit
(
'master~2'
)
commit
=
project
.
commit
(
'master'
)
earlier_commit
=
project
.
commit
(
'master~2'
)
subject
.
analyze
(
"this references commits
#{
earlier_commit
.
sha
[
0
..
6
]
}
...
#{
commit
.
sha
[
0
..
6
]
}
"
)
extracted
=
subject
.
commit_ranges
...
...
spec/mailers/notify_spec.rb
View file @
8ed7ac9d
...
...
@@ -466,7 +466,7 @@ describe Notify do
end
describe
'on a commit'
do
let
(
:commit
)
{
project
.
repository
.
commit
}
let
(
:commit
)
{
project
.
commit
}
before
(
:each
)
{
allow
(
note
).
to
receive
(
:noteable
).
and_return
(
commit
)
}
...
...
spec/models/commit_spec.rb
View file @
8ed7ac9d
...
...
@@ -2,7 +2,7 @@ require 'spec_helper'
describe
Commit
do
let
(
:project
)
{
create
:project
}
let
(
:commit
)
{
project
.
repository
.
commit
}
let
(
:commit
)
{
project
.
commit
}
describe
'#title'
do
it
"returns no_commit_message when safe_message is blank"
do
...
...
spec/models/note_spec.rb
View file @
8ed7ac9d
...
...
@@ -329,7 +329,7 @@ describe Note do
let
(
:author
)
{
create
(
:user
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:mergereq
)
{
create
(
:merge_request
,
:simple
,
target_project:
project
,
source_project:
project
)
}
let
(
:commit
)
{
project
.
repository
.
commit
}
let
(
:commit
)
{
project
.
commit
}
# Test all of {issue, merge request, commit} in both the referenced and referencing
# roles, to ensure that the correct information can be inferred from any argument.
...
...
@@ -482,8 +482,8 @@ describe Note do
let
(
:project
)
{
create
:project
}
let
(
:author
)
{
create
:user
}
let
(
:issue
)
{
create
:issue
}
let
(
:commit0
)
{
project
.
repository
.
commit
}
let
(
:commit1
)
{
project
.
repository
.
commit
(
'HEAD~2'
)
}
let
(
:commit0
)
{
project
.
commit
}
let
(
:commit1
)
{
project
.
commit
(
'HEAD~2'
)
}
before
do
Note
.
create_cross_reference_note
(
issue
,
commit0
,
author
,
project
)
...
...
spec/services/git_push_service_spec.rb
View file @
8ed7ac9d
...
...
@@ -44,7 +44,7 @@ describe GitPushService do
before
do
service
.
execute
(
project
,
user
,
@oldrev
,
@newrev
,
@ref
)
@push_data
=
service
.
push_data
@commit
=
project
.
repository
.
commit
(
@newrev
)
@commit
=
project
.
commit
(
@newrev
)
end
subject
{
@push_data
}
...
...
@@ -151,7 +151,7 @@ describe GitPushService do
describe
"cross-reference notes"
do
let
(
:issue
)
{
create
:issue
,
project:
project
}
let
(
:commit_author
)
{
create
:user
}
let
(
:commit
)
{
project
.
repository
.
commit
}
let
(
:commit
)
{
project
.
commit
}
before
do
commit
.
stub
({
...
...
@@ -198,7 +198,7 @@ describe GitPushService do
let
(
:issue
)
{
create
:issue
,
project:
project
}
let
(
:other_issue
)
{
create
:issue
,
project:
project
}
let
(
:commit_author
)
{
create
:user
}
let
(
:closing_commit
)
{
project
.
repository
.
commit
}
let
(
:closing_commit
)
{
project
.
commit
}
before
do
closing_commit
.
stub
({
...
...
spec/services/git_tag_push_service_spec.rb
View file @
8ed7ac9d
...
...
@@ -19,7 +19,7 @@ describe GitTagPushService do
@push_data
=
service
.
push_data
@tag_name
=
Gitlab
::
Git
.
ref_name
(
@ref
)
@tag
=
project
.
repository
.
find_tag
(
@tag_name
)
@commit
=
project
.
repository
.
commit
(
@tag
.
target
)
@commit
=
project
.
commit
(
@tag
.
target
)
end
subject
{
@push_data
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment