Avoid repoContr#show 404 if "Fetch changesets automatically"; fixes #6
This commit is contained in:
parent
2cfde78822
commit
547e7e9cf0
@ -36,14 +36,32 @@ class Repository::GitRemote < Repository::Git
|
|||||||
return p[:host]
|
return p[:host]
|
||||||
end
|
end
|
||||||
|
|
||||||
# hook into Repository.fetch_changesets to also run 'git fetch'
|
# Hook into Repository.fetch_changesets to also run 'git fetch'.
|
||||||
def fetch_changesets
|
def fetch_changesets
|
||||||
|
# ensure we don't fetch twice during the same request
|
||||||
|
return if @already_fetched
|
||||||
|
@already_fetched = true
|
||||||
|
|
||||||
puts "Calling fetch changesets on #{clone_path}"
|
puts "Calling fetch changesets on #{clone_path}"
|
||||||
# runs git fetch
|
# runs git fetch
|
||||||
self.fetch
|
self.fetch
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Override default_branch to fetch, otherwise caching problems in
|
||||||
|
# find_project_repository prevent Repository::Git#fetch_changesets from running.
|
||||||
|
#
|
||||||
|
# Ideally this would only be run for RepositoriesController#show.
|
||||||
|
def default_branch
|
||||||
|
if self.branches == [] && self.project.active? && Setting.autofetch_changesets?
|
||||||
|
# git_adapter#branches caches @branches incorrectly, reset it
|
||||||
|
scm.instance_variable_set :@branches, nil
|
||||||
|
# NB: fetch_changesets is idemptotent during a given request, so OK to call it 2x
|
||||||
|
self.fetch_changesets
|
||||||
|
end
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
# called in before_validate handler, sets form errors
|
# called in before_validate handler, sets form errors
|
||||||
def initialize_clone
|
def initialize_clone
|
||||||
# avoids crash in RepositoriesController#destroy
|
# avoids crash in RepositoriesController#destroy
|
||||||
|
Loading…
Reference in New Issue
Block a user