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
Léo-Paul Géneau
gitlab-ce
Commits
02d69091
Commit
02d69091
authored
Sep 20, 2016
by
Dan Dunckel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec covering 'committer_hash'
parent
422c9025
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
1 deletion
+49
-1
CHANGELOG
CHANGELOG
+1
-0
app/models/repository.rb
app/models/repository.rb
+1
-1
lib/gitlab/git.rb
lib/gitlab/git.rb
+2
-0
spec/lib/gitlab/git_spec.rb
spec/lib/gitlab/git_spec.rb
+45
-0
No files found.
CHANGELOG
View file @
02d69091
...
...
@@ -28,6 +28,7 @@ v 8.12.0 (unreleased)
- Instructions for enabling Git packfile bitmaps !6104
- Use Search::GlobalService.new in the `GET /projects/search/:query` endpoint
- Fix long comments in diffs messing with table width
- Add spec covering 'Gitlab::Git::committer_hash' !6433 (dandunckelman)
- Fix pagination on user snippets page
- Run CI builds with the permissions of users !5735
- Fix sorting of issues in API
...
...
app/models/repository.rb
View file @
02d69091
...
...
@@ -840,7 +840,7 @@ class Repository
def
get_committer_and_author
(
user
,
email:
nil
,
name:
nil
)
committer
=
user_to_committer
(
user
)
author
=
name
&&
email
?
Gitlab
::
Git
::
committer_hash
(
email:
email
,
name:
name
)
:
committer
author
=
Gitlab
::
Git
::
committer_hash
(
email:
email
,
name:
name
)
||
committer
{
author:
author
,
...
...
lib/gitlab/git.rb
View file @
02d69091
...
...
@@ -19,6 +19,8 @@ module Gitlab
end
def
committer_hash
(
email
:,
name
:)
return
if
email
.
nil?
||
name
.
nil?
{
email:
email
,
name:
name
,
...
...
spec/lib/gitlab/git_spec.rb
0 → 100644
View file @
02d69091
require
'spec_helper'
describe
Gitlab
::
Git
,
lib:
true
do
let
(
:committer_email
)
{
FFaker
::
Internet
.
email
}
# I have to remove periods from the end of the name
# This happened when the user's name had a suffix (i.e. "Sr.")
# This seems to be what git does under the hood. For example, this commit:
#
# $ git commit --author='Foo Sr. <foo@example.com>' -m 'Where's my trailing period?'
#
# results in this:
#
# $ git show --pretty
# ...
# Author: Foo Sr <foo@example.com>
# ...
let
(
:committer_name
)
{
FFaker
::
Name
.
name
.
chomp
(
"
\.
"
)
}
describe
'committer_hash'
do
it
"returns a hash containing the given email and name"
do
committer_hash
=
Gitlab
::
Git
::
committer_hash
(
email:
committer_email
,
name:
committer_name
)
expect
(
committer_hash
[
:email
]).
to
eq
(
committer_email
)
expect
(
committer_hash
[
:name
]).
to
eq
(
committer_name
)
expect
(
committer_hash
[
:time
]).
to
be_a
(
Time
)
end
context
'when email is nil'
do
it
"returns nil"
do
committer_hash
=
Gitlab
::
Git
::
committer_hash
(
email:
nil
,
name:
committer_name
)
expect
(
committer_hash
).
to
be_nil
end
end
context
'when name is nil'
do
it
"returns nil"
do
committer_hash
=
Gitlab
::
Git
::
committer_hash
(
email:
committer_email
,
name:
nil
)
expect
(
committer_hash
).
to
be_nil
end
end
end
end
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