1
1
class GitHostingSettingsObserver < ActiveRecord ::Observer
2
2
observe :setting
3
3
4
- @@old_valuehash = ( Setting . plugin_redmine_git_hosting ) . clone
4
+ @@old_valuehash = ( ( Setting . plugin_redmine_git_hosting ) . clone rescue { } )
5
5
6
6
def reload_this_observer
7
7
observed_classes . each do |klass |
@@ -31,14 +31,14 @@ def before_save(object)
31
31
32
32
# Script directory either absolute or relative to redmine root
33
33
stripped = valuehash [ 'gitScriptDir' ] . lstrip . rstrip
34
- normalizedFile = File . expand_path ( stripped , "/" ) # Get rid of extra path components
34
+ normalizedFile = File . expand_path ( stripped , "/" ) # Get rid of extra path components
35
35
if ( normalizedFile == "/" )
36
36
# Assume that we are relative bin directory ("/" and "" => "")
37
37
valuehash [ 'gitScriptDir' ] = ""
38
38
elsif ( stripped [ 0 , 1 ] != "/" )
39
- valuehash [ 'gitScriptDir' ] = normalizedFile [ 1 ..-1 ] + "/" # Clobber leading '/' add trailing '/'
39
+ valuehash [ 'gitScriptDir' ] = normalizedFile [ 1 ..-1 ] + "/" # Clobber leading '/' add trailing '/'
40
40
else
41
- valuehash [ 'gitScriptDir' ] = normalizedFile + "/" # Add trailing '/'
41
+ valuehash [ 'gitScriptDir' ] = normalizedFile + "/" # Add trailing '/'
42
42
end
43
43
elsif valuehash [ 'gitUser' ] != @@old_valuehash [ 'gitUser' ] ||
44
44
valuehash [ 'gitoliteIdentityFile' ] != @@old_valuehash [ 'gitoliteIdentityFile' ] ||
@@ -53,12 +53,12 @@ def before_save(object)
53
53
%x[ rm -rf '#{ GitHosting . get_tmp_dir } ' ]
54
54
55
55
stripped = valuehash [ 'gitTempDataDir' ] . lstrip . rstrip
56
- normalizedFile = File . expand_path ( stripped , "/" ) # Get rid of extra path components
56
+ normalizedFile = File . expand_path ( stripped , "/" ) # Get rid of extra path components
57
57
if ( normalizedFile == "/" || stripped [ 0 , 1 ] != "/" )
58
58
# Don't allow either root-level (absolute) or relative
59
59
valuehash [ 'gitTempDataDir' ] = "/tmp/redmine_git_hosting/"
60
60
else
61
- valuehash [ 'gitTempDataDir' ] = normalizedFile + "/" # Add trailing '/'
61
+ valuehash [ 'gitTempDataDir' ] = normalizedFile + "/" # Add trailing '/'
62
62
end
63
63
end
64
64
@@ -86,7 +86,7 @@ def before_save(object)
86
86
if valuehash [ 'httpServerSubdir' ]
87
87
normalizedFile = File . expand_path ( valuehash [ 'httpServerSubdir' ] . lstrip . rstrip , "/" )
88
88
if ( normalizedFile != "/" )
89
- valuehash [ 'httpServerSubdir' ] = normalizedFile [ 1 ..-1 ] + "/" # Clobber leading '/' add trailing '/'
89
+ valuehash [ 'httpServerSubdir' ] = normalizedFile [ 1 ..-1 ] + "/" # Clobber leading '/' add trailing '/'
90
90
else
91
91
valuehash [ 'httpServerSubdir' ] = ''
92
92
end
@@ -122,7 +122,7 @@ def before_save(object)
122
122
if valuehash [ 'gitRedmineSubdir' ]
123
123
normalizedFile = File . expand_path ( valuehash [ 'gitRedmineSubdir' ] . lstrip . rstrip , "/" )
124
124
if ( normalizedFile != "/" )
125
- valuehash [ 'gitRedmineSubdir' ] = normalizedFile [ 1 ..-1 ] + "/" # Clobber leading '/' add trailing '/'
125
+ valuehash [ 'gitRedmineSubdir' ] = normalizedFile [ 1 ..-1 ] + "/" # Clobber leading '/' add trailing '/'
126
126
else
127
127
valuehash [ 'gitRedmineSubdir' ] = ''
128
128
end
@@ -144,7 +144,7 @@ def before_save(object)
144
144
h [ x ] +=1 unless x . blank?
145
145
h
146
146
end . values . max ) || 0 ) > 1
147
- # Oops -- have duplication. Force to false.
147
+ # Oops -- have duplication. Force to false.
148
148
GitHosting . logger . error "Detected non-unique repository identifiers. Setting gitRepositoryIdentUnique => 'false'."
149
149
valuehash [ 'gitRepositoryIdentUnique' ] = "false"
150
150
end
0 commit comments