BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
0189be08
Unverified
Commit
0189be08
authored
Oct 10, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use short_id instead of [0..N] for short version of commit sha
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
9c824888
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
28 additions
and
21 deletions
+28
-21
commits_helper.rb
app/helpers/commits_helper.rb
+4
-0
commit.rb
app/models/commit.rb
+5
-1
event.rb
app/models/event.rb
+1
-1
merge_request_diff.rb
app/models/merge_request_diff.rb
+1
-1
_commit.html.haml
app/views/events/_commit.html.haml
+1
-1
_event_push.atom.haml
app/views/events/_event_push.atom.haml
+1
-1
_push.html.haml
app/views/events/event/_push.html.haml
+1
-1
_commit_box.html.haml
app/views/projects/commit/_commit_box.html.haml
+1
-1
_submodule_item.html.haml
app/views/projects/tree/_submodule_item.html.haml
+2
-2
history.html.haml
app/views/projects/wikis/history.html.haml
+1
-1
_note.html.haml
app/views/search/results/_note.html.haml
+1
-1
commits.rb
features/steps/project/commits/commits.rb
+1
-1
commit_spec.rb
spec/models/commit_spec.rb
+1
-1
note_spec.rb
spec/models/note_spec.rb
+2
-2
mentionable_shared_examples.rb
spec/support/mentionable_shared_examples.rb
+5
-6
No files found.
app/helpers/commits_helper.rb
View file @
0189be08
...
...
@@ -120,4 +120,8 @@ module CommitsHelper
class:
'commit-short-id'
)
end
end
def
truncate_sha
(
sha
)
Commit
.
truncate_sha
(
sha
)
end
end
app/models/commit.rb
View file @
0189be08
...
...
@@ -26,6 +26,10 @@ class Commit
def
diff_line_count
(
diffs
)
diffs
.
reduce
(
0
)
{
|
sum
,
d
|
sum
+
d
.
diff
.
lines
.
count
}
end
def
truncate_sha
(
sha
)
sha
[
0
..
10
]
end
end
attr_accessor
:raw
...
...
@@ -111,7 +115,7 @@ class Commit
# Mentionable override.
def
gfm_reference
"commit
#{
sh
a
[
0
..
5
]
}
"
"commit
#{
sh
ort_id
}
"
end
def
method_missing
(
m
,
*
args
,
&
block
)
...
...
app/models/event.rb
View file @
0189be08
...
...
@@ -266,7 +266,7 @@ class Event < ActiveRecord::Base
end
def
note_short_commit_id
note_commit_id
[
0
..
8
]
Commit
.
truncate_sha
(
note_commit_id
)
end
def
note_commit?
...
...
app/models/merge_request_diff.rb
View file @
0189be08
...
...
@@ -55,7 +55,7 @@ class MergeRequestDiff < ActiveRecord::Base
end
def
last_commit_short_sha
@last_commit_short_sha
||=
last_commit
.
sh
a
[
0
..
10
]
@last_commit_short_sha
||=
last_commit
.
sh
ort_id
end
private
...
...
app/views/events/_commit.html.haml
View file @
0189be08
%li
.commit
.commit-row-title
=
link_to
commit
[
:id
][
0
..
8
]
,
project_commit_path
(
project
,
commit
[
:id
]),
class:
"commit_short_id"
,
alt:
''
=
link_to
truncate_sha
(
commit
[
:id
])
,
project_commit_path
(
project
,
commit
[
:id
]),
class:
"commit_short_id"
,
alt:
''
=
gfm
event_commit_title
(
commit
[
:message
]),
project
app/views/events/_event_push.atom.haml
View file @
0189be08
...
...
@@ -2,7 +2,7 @@
-
event
.
commits
.
first
(
15
).
each
do
|
commit
|
%p
%strong
=
commit
[
:author
][
:name
]
=
link_to
"(#
#{
commit
[
:id
][
0
...
8
]
}
)"
,
project_commit_path
(
event
.
project
,
id:
commit
[
:id
])
=
link_to
"(#
#{
truncate_sha
(
commit
[
:id
])
}
)"
,
project_commit_path
(
event
.
project
,
id:
commit
[
:id
])
%i
at
=
commit
[
:timestamp
].
to_time
.
to_s
(
:short
)
...
...
app/views/events/event/_push.html.haml
View file @
0189be08
...
...
@@ -22,4 +22,4 @@
-
if
event
.
commits_count
>
2
%span
... and
#{
event
.
commits_count
-
2
}
more commits.
=
link_to
project_compare_path
(
event
.
project
,
from:
event
.
commit_from
,
to:
event
.
commit_to
)
do
%strong
Compare
→
#{
event
.
commit_from
[
0
..
7
]
}
...
#{
event
.
commit_to
[
0
..
7
]
}
%strong
Compare
→
#{
truncate_sha
(
event
.
commit_from
)
}
...
#{
truncate_sha
(
event
.
commit_to
)
}
app/views/projects/commit/_commit_box.html.haml
View file @
0189be08
...
...
@@ -35,7 +35,7 @@
.commit-info-row
%span
.cgray
=
pluralize
(
@commit
.
parents
.
count
,
"parent"
)
-
@commit
.
parents
.
each
do
|
parent
|
=
link_to
parent
.
id
[
0
...
10
]
,
project_commit_path
(
@project
,
parent
)
=
link_to
parent
.
short_id
,
project_commit_path
(
@project
,
parent
)
-
if
@branches
.
any?
.commit-info-row
...
...
app/views/projects/tree/_submodule_item.html.haml
View file @
0189be08
...
...
@@ -7,8 +7,8 @@
@
%span
.monospace
-
if
commit
.
nil?
#{
submodule_item
.
id
[
0
..
10
]
}
#{
truncate_sha
(
submodule_item
.
id
)
}
-
else
=
link_to
"
#{
submodule_item
.
id
[
0
..
10
]
}
"
,
commit
=
link_to
"
#{
truncate_sha
(
submodule_item
.
id
)
}
"
,
commit
%td
%td
.hidden-xs
app/views/projects/wikis/history.html.haml
View file @
0189be08
...
...
@@ -17,7 +17,7 @@
%tr
%td
=
link_to
project_wiki_path
(
@project
,
@page
,
version_id:
commit
.
id
)
do
=
commit
.
id
[
0
..
10
]
=
truncate_sha
(
commit
.
id
)
%td
=
commit
.
author
.
name
%td
...
...
app/views/search/results/_note.html.haml
View file @
0189be08
...
...
@@ -10,7 +10,7 @@
=
project
.
name_with_namespace
·
=
link_to
project_commit_path
(
project
,
note
.
commit_id
,
anchor:
dom_id
(
note
))
do
Commit
#{
note
.
commit_id
[
0
..
8
]
}
Commit
#{
truncate_sha
(
note
.
commit_id
)
}
-
else
=
link_to
project
do
=
project
.
name_with_namespace
...
...
features/steps/project/commits/commits.rb
View file @
0189be08
...
...
@@ -8,7 +8,7 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps
commit
=
@project
.
repository
.
commit
page
.
should
have_content
(
@project
.
name
)
page
.
should
have_content
(
commit
.
message
[
0
..
20
])
page
.
should
have_content
(
commit
.
id
.
to_s
[
0
..
5
]
)
page
.
should
have_content
(
commit
.
short_id
)
end
step
'I click atom feed link'
do
...
...
spec/models/commit_spec.rb
View file @
0189be08
...
...
@@ -75,7 +75,7 @@ eos
it_behaves_like
'a mentionable'
do
let
(
:subject
)
{
commit
}
let
(
:mauthor
)
{
create
:user
,
email:
commit
.
author_email
}
let
(
:backref_text
)
{
"commit
#{
subject
.
sh
a
[
0
..
5
]
}
"
}
let
(
:backref_text
)
{
"commit
#{
subject
.
sh
ort_id
}
"
}
let
(
:set_mentionable_text
)
{
->
(
txt
){
subject
.
stub
(
safe_message:
txt
)
}
}
# Include the subject in the repository stub.
...
...
spec/models/note_spec.rb
View file @
0189be08
...
...
@@ -228,7 +228,7 @@ describe Note do
it
{
should
be_valid
}
its
(
:noteable
)
{
should
==
issue
}
its
(
:note
)
{
should
==
"_mentioned in commit
#{
commit
.
sha
[
0
..
5
]
}
_"
}
its
(
:note
)
{
should
==
"_mentioned in commit
#{
commit
.
sha
[
0
..
10
]
}
_"
}
end
context
'merge request from an issue'
do
...
...
@@ -267,7 +267,7 @@ describe Note do
its
(
:noteable_type
)
{
should
==
"Commit"
}
its
(
:noteable_id
)
{
should
be_nil
}
its
(
:commit_id
)
{
should
==
commit
.
id
}
its
(
:note
)
{
should
==
"_mentioned in commit
#{
parent_commit
.
id
[
0
..
.
6
]
}
_"
}
its
(
:note
)
{
should
==
"_mentioned in commit
#{
parent_commit
.
id
[
0
..
10
]
}
_"
}
end
end
...
...
spec/support/mentionable_shared_examples.rb
View file @
0189be08
...
...
@@ -30,15 +30,15 @@ def common_mentionable_setup
"!
#{
mentioned_mr
.
iid
}
, "
+
"
#{
ext_proj
.
path_with_namespace
}
#
#{
ext_issue
.
iid
}
, "
+
"
#{
ext_proj
.
path_with_namespace
}
!
#{
ext_mr
.
iid
}
, "
+
"
#{
ext_proj
.
path_with_namespace
}
@
#{
ext_commit
.
id
[
0
..
5
]
}
, "
+
"
#{
mentioned_commit
.
sha
[
0
..
5
]
}
and itself as
#{
backref_text
}
"
"
#{
ext_proj
.
path_with_namespace
}
@
#{
ext_commit
.
short_id
}
, "
+
"
#{
mentioned_commit
.
sha
[
0
..
10
]
}
and itself as
#{
backref_text
}
"
end
before
do
# Wire the project's repository to return the mentioned commit, and +nil+ for any
# unrecognized commits.
commitmap
=
{
'123456'
=>
mentioned_commit
}
extra_commits
.
each
{
|
c
|
commitmap
[
c
.
sh
a
[
0
..
5
]
]
=
c
}
commitmap
=
{
'123456
7890a
'
=>
mentioned_commit
}
extra_commits
.
each
{
|
c
|
commitmap
[
c
.
sh
ort_id
]
=
c
}
mproject
.
repository
.
stub
(
:commit
)
{
|
sha
|
commitmap
[
sha
]
}
set_mentionable_text
.
call
(
ref_string
)
end
...
...
@@ -54,7 +54,6 @@ shared_examples 'a mentionable' do
it
"extracts references from its reference property"
do
# De-duplicate and omit itself
refs
=
subject
.
references
(
mproject
)
refs
.
should
have
(
6
).
items
refs
.
should
include
(
mentioned_issue
)
refs
.
should
include
(
mentioned_mr
)
...
...
@@ -90,7 +89,7 @@ shared_examples 'an editable mentionable' do
it
'creates new cross-reference notes when the mentionable text is edited'
do
new_text
=
"still mentions #
#{
mentioned_issue
.
iid
}
, "
+
"
#{
mentioned_commit
.
sha
[
0
..
5
]
}
, "
+
"
#{
mentioned_commit
.
sha
[
0
..
10
]
}
, "
+
"
#{
ext_issue
.
iid
}
, "
+
"new refs: #
#{
other_issue
.
iid
}
, "
+
"
#{
ext_proj
.
path_with_namespace
}
#
#{
other_ext_issue
.
iid
}
"
...
...
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