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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
bbc2ebd1
Commit
bbc2ebd1
authored
Mar 22, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
a971e201
3eba3a18
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
1 deletion
+44
-1
app/models/project.rb
app/models/project.rb
+1
-0
app/workers/project_cache_worker.rb
app/workers/project_cache_worker.rb
+1
-0
changelogs/unreleased/refresh-commit-count-after-head-change.yml
...ogs/unreleased/refresh-commit-count-after-head-change.yml
+5
-0
changelogs/unreleased/retain-default-branch-on-import.yml
changelogs/unreleased/retain-default-branch-on-import.yml
+5
-0
lib/gitlab/github_import/importer/repository_importer.rb
lib/gitlab/github_import/importer/repository_importer.rb
+15
-1
spec/lib/gitlab/github_import/importer/repository_importer_spec.rb
...gitlab/github_import/importer/repository_importer_spec.rb
+11
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+6
-0
No files found.
app/models/project.rb
View file @
bbc2ebd1
...
@@ -1384,6 +1384,7 @@ class Project < ActiveRecord::Base
...
@@ -1384,6 +1384,7 @@ class Project < ActiveRecord::Base
repository
.
raw_repository
.
write_ref
(
'HEAD'
,
"refs/heads/
#{
branch
}
"
)
repository
.
raw_repository
.
write_ref
(
'HEAD'
,
"refs/heads/
#{
branch
}
"
)
repository
.
copy_gitattributes
(
branch
)
repository
.
copy_gitattributes
(
branch
)
repository
.
after_change_head
repository
.
after_change_head
ProjectCacheWorker
.
perform_async
(
self
.
id
,
[],
[
:commit_count
])
reload_default_branch
reload_default_branch
else
else
errors
.
add
(
:base
,
"Could not change HEAD: branch '
#{
branch
}
' does not exist"
)
errors
.
add
(
:base
,
"Could not change HEAD: branch '
#{
branch
}
' does not exist"
)
...
...
app/workers/project_cache_worker.rb
View file @
bbc2ebd1
...
@@ -26,6 +26,7 @@ class ProjectCacheWorker
...
@@ -26,6 +26,7 @@ class ProjectCacheWorker
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
def
update_statistics
(
project
,
statistics
=
[])
def
update_statistics
(
project
,
statistics
=
[])
return
if
Gitlab
::
Database
.
read_only?
return
unless
try_obtain_lease_for
(
project
.
id
,
:update_statistics
)
return
unless
try_obtain_lease_for
(
project
.
id
,
:update_statistics
)
Rails
.
logger
.
info
(
"Updating statistics for project
#{
project
.
id
}
"
)
Rails
.
logger
.
info
(
"Updating statistics for project
#{
project
.
id
}
"
)
...
...
changelogs/unreleased/refresh-commit-count-after-head-change.yml
0 → 100644
View file @
bbc2ebd1
---
title
:
Refresh commit count after repository head changes
merge_request
:
26473
author
:
type
:
fixed
changelogs/unreleased/retain-default-branch-on-import.yml
0 → 100644
View file @
bbc2ebd1
---
title
:
Set proper default-branch for repository on GitHub Import
merge_request
:
26476
author
:
type
:
fixed
lib/gitlab/github_import/importer/repository_importer.rb
View file @
bbc2ebd1
...
@@ -5,6 +5,7 @@ module Gitlab
...
@@ -5,6 +5,7 @@ module Gitlab
module
Importer
module
Importer
class
RepositoryImporter
class
RepositoryImporter
include
Gitlab
::
ShellAdapter
include
Gitlab
::
ShellAdapter
include
Gitlab
::
Utils
::
StrongMemoize
attr_reader
:project
,
:client
,
:wiki_formatter
attr_reader
:project
,
:client
,
:wiki_formatter
...
@@ -17,7 +18,7 @@ module Gitlab
...
@@ -17,7 +18,7 @@ module Gitlab
# Returns true if we should import the wiki for the project.
# Returns true if we should import the wiki for the project.
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
import_wiki?
def
import_wiki?
client
.
repository
(
project
.
import_source
)
&
.
has_wiki
&&
client
_repository
&
.
has_wiki
&&
!
project
.
wiki_repository_exists?
&&
!
project
.
wiki_repository_exists?
&&
Gitlab
::
GitalyClient
::
RemoteService
.
exists?
(
wiki_url
)
Gitlab
::
GitalyClient
::
RemoteService
.
exists?
(
wiki_url
)
end
end
...
@@ -52,6 +53,7 @@ module Gitlab
...
@@ -52,6 +53,7 @@ module Gitlab
refmap
=
Gitlab
::
GithubImport
.
refmap
refmap
=
Gitlab
::
GithubImport
.
refmap
project
.
repository
.
fetch_as_mirror
(
project
.
import_url
,
refmap:
refmap
,
forced:
true
,
remote_name:
'github'
)
project
.
repository
.
fetch_as_mirror
(
project
.
import_url
,
refmap:
refmap
,
forced:
true
,
remote_name:
'github'
)
project
.
change_head
(
default_branch
)
if
default_branch
true
true
rescue
Gitlab
::
Git
::
Repository
::
NoRepository
,
Gitlab
::
Shell
::
Error
=>
e
rescue
Gitlab
::
Git
::
Repository
::
NoRepository
,
Gitlab
::
Shell
::
Error
=>
e
fail_import
(
"Failed to import the repository:
#{
e
.
message
}
"
)
fail_import
(
"Failed to import the repository:
#{
e
.
message
}
"
)
...
@@ -82,6 +84,18 @@ module Gitlab
...
@@ -82,6 +84,18 @@ module Gitlab
project
.
import_state
.
mark_as_failed
(
message
)
project
.
import_state
.
mark_as_failed
(
message
)
false
false
end
end
private
def
default_branch
client_repository
&
.
default_branch
end
def
client_repository
strong_memoize
(
:client_repository
)
do
client
.
repository
(
project
.
import_source
)
end
end
end
end
end
end
end
end
...
...
spec/lib/gitlab/github_import/importer/repository_importer_spec.rb
View file @
bbc2ebd1
...
@@ -179,6 +179,17 @@ describe Gitlab::GithubImport::Importer::RepositoryImporter do
...
@@ -179,6 +179,17 @@ describe Gitlab::GithubImport::Importer::RepositoryImporter do
describe
'#import_repository'
do
describe
'#import_repository'
do
it
'imports the repository'
do
it
'imports the repository'
do
repo
=
double
(
:repo
,
default_branch:
'develop'
)
expect
(
client
)
.
to
receive
(
:repository
)
.
with
(
'foo/bar'
)
.
and_return
(
repo
)
expect
(
project
)
.
to
receive
(
:change_head
)
.
with
(
'develop'
)
expect
(
project
)
expect
(
project
)
.
to
receive
(
:ensure_repository
)
.
to
receive
(
:ensure_repository
)
...
...
spec/models/project_spec.rb
View file @
bbc2ebd1
...
@@ -2630,6 +2630,12 @@ describe Project do
...
@@ -2630,6 +2630,12 @@ describe Project do
project
.
change_head
(
project
.
default_branch
)
project
.
change_head
(
project
.
default_branch
)
end
end
it
'updates commit count'
do
expect
(
ProjectCacheWorker
).
to
receive
(
:perform_async
).
with
(
project
.
id
,
[],
[
:commit_count
])
project
.
change_head
(
project
.
default_branch
)
end
it
'copies the gitattributes'
do
it
'copies the gitattributes'
do
expect
(
project
.
repository
).
to
receive
(
:copy_gitattributes
).
with
(
project
.
default_branch
)
expect
(
project
.
repository
).
to
receive
(
:copy_gitattributes
).
with
(
project
.
default_branch
)
project
.
change_head
(
project
.
default_branch
)
project
.
change_head
(
project
.
default_branch
)
...
...
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