Bug #2102
Code to strip '.git' extensions is not correct.
100%
Description
The code (regular expression) to strip the '.git’ extension from repository paths is not correct. It now also strips anything that ends with any character followed by 'git’.
This is the result of constructing a regular expression from a string and forgetting the rule that in a string to get an escape character you have to escape that escape, i.e. “\\”.
Below the patch I made to fix this.
diff --git a/plugins/redmine_scm/lib/creator/git_creator.rb b/plugins/redmine_scm/lib/creator/git_creator.rb
index 14148ce..f50c150 100644
--- a/plugins/redmine_scm/lib/creator/git_creator.rb
+++ b/plugins/redmine_scm/lib/creator/git_creator.rb
@@ -36,7 +36,7 @@ class GitCreator < SCMCreator
def repository_name(path)
base = Redmine::Platform.mswin? ? options['path'].gsub(%r{\\}, "/") : options['path']
- matches = Regexp.new("^#{Regexp.escape(base)}/([^/]+?)(\.git)?/?$").match(path)
+ matches = Regexp.new("^#{Regexp.escape(base)}/([^/]+?)(\\.git)?/?$").match(path)
matches ? matches[1] : nil
end
Related issues
Associated revisions
History
#1 Updated by Andriy Lesyuk about 12 years ago
- Status changed from New to Open
- Assignee set to Andriy Lesyuk
Thanks for the patch!
#2 Updated by Andriy Lesyuk about 12 years ago
- Target version set to 0.4.2
#3 Updated by Andriy Lesyuk about 12 years ago
- Due date set to 14 Nov 2012
- Status changed from Open to Closed
- % Done changed from 0 to 100
Not yet committed...