Skip to content

Commit 58b1738

Browse files
author
root
committed
set_identifier should be private
1 parent 36f5420 commit 58b1738

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

Diff for: app/models/gitolite_public_key.rb

+26-26
Original file line numberDiff line numberDiff line change
@@ -48,32 +48,6 @@ def to_s
4848
end
4949

5050

51-
def set_identifier
52-
self.identifier ||=
53-
begin
54-
my_time = Time.now
55-
time_tag = "#{my_time.to_i.to_s}_#{my_time.usec.to_s}"
56-
key_count = GitolitePublicKey.by_user(self.user).deploy_key.length + 1
57-
case key_type
58-
when KEY_TYPE_USER
59-
# add "redmine_" as a prefix to the username, and then the current date
60-
# this helps ensure uniqueness of each key identifier
61-
#
62-
# also, it ensures that it is very, very unlikely to conflict with any
63-
# existing key name if gitolite config is also being edited manually
64-
"#{self.user.gitolite_identifier}" << "@redmine_" << "#{time_tag}".gsub(/[^0-9a-zA-Z\-]/, '_')
65-
when KEY_TYPE_DEPLOY
66-
# add "redmine_deploy_key_" as a prefix, and then the current date
67-
# to help ensure uniqueness of each key identifier
68-
# "redmine_#{DEPLOY_PSEUDO_USER}_#{time_tag}".gsub(/[^0-9a-zA-Z\-]/, '_') << "@redmine_" << "#{time_tag}".gsub(/[^0-9a-zA-Z\-]/, '_')
69-
"#{self.user.gitolite_identifier}_#{DEPLOY_PSEUDO_USER}_#{key_count}".gsub(/[^0-9a-zA-Z\-]/, '_') << "@redmine_" << "#{time_tag}".gsub(/[^0-9a-zA-Z\-]/, '_')
70-
else
71-
nil
72-
end
73-
end
74-
end
75-
76-
7751
# Make sure that current identifier is consistent with current user login.
7852
# This method explicitly overrides the static nature of the identifier
7953
def reset_identifier
@@ -246,4 +220,30 @@ def key_uniqueness
246220
return true
247221
end
248222

223+
224+
def set_identifier
225+
self.identifier ||=
226+
begin
227+
my_time = Time.now
228+
time_tag = "#{my_time.to_i.to_s}_#{my_time.usec.to_s}"
229+
key_count = GitolitePublicKey.by_user(self.user).deploy_key.length + 1
230+
case key_type
231+
when KEY_TYPE_USER
232+
# add "redmine_" as a prefix to the username, and then the current date
233+
# this helps ensure uniqueness of each key identifier
234+
#
235+
# also, it ensures that it is very, very unlikely to conflict with any
236+
# existing key name if gitolite config is also being edited manually
237+
"#{self.user.gitolite_identifier}" << "@redmine_" << "#{time_tag}".gsub(/[^0-9a-zA-Z\-]/, '_')
238+
when KEY_TYPE_DEPLOY
239+
# add "redmine_deploy_key_" as a prefix, and then the current date
240+
# to help ensure uniqueness of each key identifier
241+
# "redmine_#{DEPLOY_PSEUDO_USER}_#{time_tag}".gsub(/[^0-9a-zA-Z\-]/, '_') << "@redmine_" << "#{time_tag}".gsub(/[^0-9a-zA-Z\-]/, '_')
242+
"#{self.user.gitolite_identifier}_#{DEPLOY_PSEUDO_USER}_#{key_count}".gsub(/[^0-9a-zA-Z\-]/, '_') << "@redmine_" << "#{time_tag}".gsub(/[^0-9a-zA-Z\-]/, '_')
243+
else
244+
nil
245+
end
246+
end
247+
end
248+
249249
end

0 commit comments

Comments
 (0)