diff options
author | Robert Speicher <rspeicher@gmail.com> | 2017-01-04 21:43:06 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2017-01-05 03:09:28 +0300 |
commit | a00578ce5cdf4bab95990bca9e806c6322bb1384 (patch) | |
tree | 5aafe058fa55086038dbb3086121ad624447c0e4 /lib/gitlab/git/path_helper.rb | |
parent | aec04a47c16665f1dfb1fb61647c3f78a4dde20f (diff) |
Absorb gitlab_git
Diffstat (limited to 'lib/gitlab/git/path_helper.rb')
-rw-r--r-- | lib/gitlab/git/path_helper.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/gitlab/git/path_helper.rb b/lib/gitlab/git/path_helper.rb new file mode 100644 index 00000000000..0148cd8df05 --- /dev/null +++ b/lib/gitlab/git/path_helper.rb @@ -0,0 +1,16 @@ +module Gitlab + module Git + class PathHelper + class << self + def normalize_path(filename) + # Strip all leading slashes so that //foo -> foo + filename[/^\/*/] = '' + + # Expand relative paths (e.g. foo/../bar) + filename = Pathname.new(filename) + filename.relative_path_from(Pathname.new('')) + end + end + end + end +end |