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
34fbade4
Unverified
Commit
34fbade4
authored
Mar 01, 2018
by
Zeger-Jan van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Client implementation for Licensee#key
Part of the migration as tracked in: gitlab-org/gitaly#1026
parent
e66e7767
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
9 deletions
+53
-9
repository.rb
app/models/repository.rb
+1
-9
repository.rb
lib/gitlab/git/repository.rb
+15
-0
repository_service.rb
lib/gitlab/gitaly_client/repository_service.rb
+8
-0
repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+29
-0
No files found.
app/models/repository.rb
View file @
34fbade4
...
...
@@ -589,15 +589,7 @@ class Repository
def
license_key
return
unless
exists?
# The licensee gem creates a Rugged object from the path:
# https://github.com/benbalter/licensee/blob/v8.7.0/lib/licensee/projects/git_project.rb
begin
Licensee
.
license
(
path
).
try
(
:key
)
# Normally we would rescue Rugged::Error, but that is banned by lint-rugged
# and we need to migrate this endpoint to Gitaly:
# https://gitlab.com/gitlab-org/gitaly/issues/1026
rescue
end
raw_repository
.
license_short_name
end
cache_method
:license_key
...
...
lib/gitlab/git/repository.rb
View file @
34fbade4
...
...
@@ -1032,6 +1032,21 @@ module Gitlab
end
end
def
license_short_name
gitaly_migrate
(
:license_short_name
)
do
|
is_enabled
|
if
is_enabled
gitaly_repository_client
.
license_short_name
else
begin
# The licensee gem creates a Rugged object from the path:
# https://github.com/benbalter/licensee/blob/v8.7.0/lib/licensee/projects/git_project.rb
Licensee
.
license
(
path
).
try
(
:key
)
rescue
Rugged
::
Error
end
end
end
end
def
with_repo_branch_commit
(
start_repository
,
start_branch_name
)
Gitlab
::
Git
.
check_namespace!
(
start_repository
)
start_repository
=
RemoteRepository
.
new
(
start_repository
)
unless
start_repository
.
is_a?
(
RemoteRepository
)
...
...
lib/gitlab/gitaly_client/repository_service.rb
View file @
34fbade4
...
...
@@ -249,6 +249,14 @@ module Gitlab
raise
Gitlab
::
Git
::
OSError
.
new
(
response
.
error
)
unless
response
.
error
.
empty?
end
def
license_short_name
request
=
Gitaly
::
FindLicenseRequest
.
new
(
repository:
@gitaly_repo
)
response
=
GitalyClient
.
call
(
@storage
,
:repository_service
,
:find_license
,
request
,
timeout:
GitalyClient
.
fast_timeout
)
response
.
license_short_name
.
presence
end
end
end
end
spec/lib/gitlab/git/repository_spec.rb
View file @
34fbade4
...
...
@@ -1649,6 +1649,35 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
end
describe
'#license_short_name'
do
shared_examples
'acquiring the Licensee license key'
do
subject
{
repository
.
license_short_name
}
context
'when no license file can be found'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:repository
)
{
project
.
repository
.
raw_repository
}
before
do
project
.
repository
.
delete_file
(
project
.
owner
,
'LICENSE'
,
message:
'remove license'
,
branch_name:
'master'
)
end
it
{
is_expected
.
to
be_nil
}
end
context
'when an mit license is found'
do
it
{
is_expected
.
to
eq
(
'mit'
)
}
end
end
context
'when gitaly is enabled'
do
it_behaves_like
'acquiring the Licensee license key'
end
context
'when gitaly is disabled'
,
:disable_gitaly
do
it_behaves_like
'acquiring the Licensee license key'
end
end
describe
'#with_repo_branch_commit'
do
context
'when comparing with the same repository'
do
let
(
:start_repository
)
{
repository
}
...
...
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