Skip to content

Commit 36f6047

Browse files
committed
Don't look at repository identifier unless we are in multi-repo mode.
1 parent 028ee9a commit 36f6047

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Diff for: lib/git_hosting/patches/repository_patch.rb

+7-4
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@ def repo_ident_unique?
2828
# repository. If switching back and forth between the "repo_ident_unique?"
2929
# form, it will still identify the repository (as long as there are not more than
3030
# one repo with the same identifier.
31+
#
32+
# Note about pre Redmine 1.4 -- only look at last component and try to match to a path.
33+
# If that doesn't work, return nil.
3134
def find_by_path(path,flags={})
3235
if parseit = path.match(/^.*?(([^\/]+)\/)?([^\/]+?)(\.git)?$/)
33-
if proj=Project.find_by_identifier(parseit[3])
36+
if proj=Project.find_by_identifier(parseit[3]) || !GitHosting.multi_repos?
3437
# return default or first repo with blank identifier (or first Git repo--very rare?)
35-
proj.repository || proj.repo_blank_ident || proj.gl_repos.first
38+
proj && (proj.repository || proj.repo_blank_ident || proj.gl_repos.first)
3639
elsif repo_ident_unique? || flags[:loose] && parseit[2].nil?
3740
find_by_identifier(parseit[3])
3841
elsif parseit[2] && proj = Project.find_by_identifier(parseit[2])
@@ -132,7 +135,7 @@ def extra=(new_extra_struct)
132135
# Else, use directory notation: <project identifier>/<repo identifier>
133136
def git_label(flags=nil)
134137
isunique=(flags ? flags[:assume_unique] : self.class.repo_ident_unique?)
135-
if identifier.blank? || !GitHosting.multi_repos?
138+
if !GitHosting.multi_repos? || identifier.blank?
136139
# Should only happen with one repo/project (the default)
137140
project.identifier
138141
elsif isunique
@@ -144,7 +147,7 @@ def git_label(flags=nil)
144147

145148
# This is the (possibly non-unique) basename for the git repository
146149
def git_name
147-
(identifier.blank? || !GitHosting.multi_repos?) ? project.identifier : identifier
150+
(!GitHosting.multi_repos? || identifier.blank?) ? project.identifier : identifier
148151
end
149152

150153
# Check several aspects of repository identifier (only for Redmine 1.4+)

0 commit comments

Comments
 (0)