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
f96b4f41
Commit
f96b4f41
authored
Oct 03, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fetch the remote if a PR has been created/updated after the last fetch
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
80e4fee7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
lib/github/import.rb
lib/github/import.rb
+14
-4
No files found.
lib/github/import.rb
View file @
f96b4f41
...
...
@@ -9,7 +9,7 @@ module Github
include
Gitlab
::
ShellAdapter
attr_reader
:project
,
:repository
,
:repo
,
:repo_url
,
:wiki_url
,
:options
,
:errors
,
:cached
,
:verbose
:options
,
:errors
,
:cached
,
:verbose
,
:last_fetched_at
def
initialize
(
project
,
options
=
{})
@project
=
project
...
...
@@ -21,12 +21,13 @@ module Github
@verbose
=
options
.
fetch
(
:verbose
,
false
)
@cached
=
Hash
.
new
{
|
hash
,
key
|
hash
[
key
]
=
Hash
.
new
}
@errors
=
[]
@last_fetched_at
=
nil
end
# rubocop: disable Rails/Output
def
execute
puts
'Fetching repository...'
.
color
(
:aqua
)
if
verbose
fetch_repository
setup_and_
fetch_repository
puts
'Fetching labels...'
.
color
(
:aqua
)
if
verbose
fetch_labels
puts
'Fetching milestones...'
.
color
(
:aqua
)
if
verbose
...
...
@@ -52,19 +53,24 @@ module Github
private
def
fetch_repository
def
setup_and_
fetch_repository
begin
project
.
ensure_repository
project
.
repository
.
add_remote
(
'github'
,
repo_url
)
project
.
repository
.
set_import_remote_as_mirror
(
'github'
)
project
.
repository
.
add_remote_fetch_config
(
'github'
,
'+refs/pull/*/head:refs/merge-requests/*/head'
)
project
.
repository
.
fetch_remote
(
'github'
,
forced:
true
)
fetch_remote
(
forced:
true
)
rescue
Gitlab
::
Git
::
Repository
::
NoRepository
,
Gitlab
::
Shell
::
Error
=>
e
error
(
:project
,
repo_url
,
e
.
message
)
raise
Github
::
RepositoryFetchError
end
end
def
fetch_remote
(
forced:
false
)
@last_fetched_at
=
Time
.
now
project
.
repository
.
fetch_remote
(
'github'
,
forced:
forced
)
end
def
fetch_wiki_repository
return
if
project
.
wiki
.
repository_exists?
...
...
@@ -144,6 +150,10 @@ module Github
next
unless
merge_request
.
new_record?
&&
pull_request
.
valid?
begin
# If the PR has been created/updated after we last fetched the
# remote, we fetch again to get the up-to-date refs.
fetch_remote
if
pull_request
.
updated_at
>
last_fetched_at
author_id
=
user_id
(
pull_request
.
author
,
project
.
creator_id
)
description
=
format_description
(
pull_request
.
description
,
pull_request
.
author
)
...
...
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