From 96f346627e25bbfdf19f22dfd15c6f568d3aebaf Mon Sep 17 00:00:00 2001 From: Andreas Wass Date: Tue, 28 Feb 2017 10:12:48 +0100 Subject: [PATCH] Add support for local protocol (file://) --- app/models/repository/git_remote.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/models/repository/git_remote.rb b/app/models/repository/git_remote.rb index f5c0b2d..c3d01d0 100644 --- a/app/models/repository/git_remote.rb +++ b/app/models/repository/git_remote.rb @@ -37,13 +37,21 @@ def clone_host return p[:host] end + def clone_protocol_file? + # Check if the repository is a local protocol. Only local protocol of the + # form file:// is supported by this method. + clone_url.match(/^file/) + end + def clone_protocol_ssh? # Possible valid values (via http://git-scm.com/book/ch4-1.html): + # /path/project.git + # file:///path/project.git # ssh://user@server/project.git # user@server:project.git # server:project.git - # For simplicity we just assume if it's not HTTP(S), then it's SSH. - !clone_url.match(/^http/) + # For simplicity we just assume if it's not HTTP(S) or file, then it's SSH. + !clone_url.match(/^http/) && !clone_protocol_file end # Hook into Repository.fetch_changesets to also run 'git fetch'.