@@ -28,11 +28,14 @@ def repo_ident_unique?
28
28
# repository. If switching back and forth between the "repo_ident_unique?"
29
29
# form, it will still identify the repository (as long as there are not more than
30
30
# 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.
31
34
def find_by_path ( path , flags = { } )
32
35
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?
34
37
# 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 )
36
39
elsif repo_ident_unique? || flags [ :loose ] && parseit [ 2 ] . nil?
37
40
find_by_identifier ( parseit [ 3 ] )
38
41
elsif parseit [ 2 ] && proj = Project . find_by_identifier ( parseit [ 2 ] )
@@ -132,7 +135,7 @@ def extra=(new_extra_struct)
132
135
# Else, use directory notation: <project identifier>/<repo identifier>
133
136
def git_label ( flags = nil )
134
137
isunique = ( flags ? flags [ :assume_unique ] : self . class . repo_ident_unique? )
135
- if identifier . blank ? || ! GitHosting . multi_repos ?
138
+ if ! GitHosting . multi_repos ? || identifier . blank ?
136
139
# Should only happen with one repo/project (the default)
137
140
project . identifier
138
141
elsif isunique
@@ -144,7 +147,7 @@ def git_label(flags=nil)
144
147
145
148
# This is the (possibly non-unique) basename for the git repository
146
149
def git_name
147
- ( identifier . blank ? || ! GitHosting . multi_repos ?) ? project . identifier : identifier
150
+ ( ! GitHosting . multi_repos ? || identifier . blank ?) ? project . identifier : identifier
148
151
end
149
152
150
153
# Check several aspects of repository identifier (only for Redmine 1.4+)
0 commit comments