doctor: check if Git remotes match db URLs
Co-authored-by: Pablo Santiago Blum de Aguiar <scorphus@gmail.com>pull/851/head
parent
90f875e02d
commit
c20ff54a75
@ -0,0 +1,13 @@
|
||||
function omf.repo.remote_uri -a repo_dir -a branch
|
||||
test -z "$repo_dir"; and set repo_dir "$PWD"
|
||||
set -l git_dir (command git -C "$repo_dir" rev-parse --show-toplevel 2>/dev/null)
|
||||
and test "$git_dir" = "$repo_dir"
|
||||
or return 1
|
||||
|
||||
test -z "$branch"; and set branch 'master'
|
||||
|
||||
set -l remote (command git -C "$repo_dir" config --get branch."$branch".remote)
|
||||
or set -l remote origin
|
||||
|
||||
command git -C "$repo_dir" config --get remote."$remote".url
|
||||
end
|
@ -0,0 +1,23 @@
|
||||
function omf.repo.uri_components -a uri
|
||||
test -n "$uri"
|
||||
or return 1
|
||||
|
||||
switch $uri
|
||||
case 'git@*'
|
||||
echo $uri | sed -r 's/git@([^:]+):([^/]+)\/([^.]+).*/\1 \2 \3/g'
|
||||
case 'http*://*'
|
||||
echo $uri | sed -r 's/https?:\/\/([^:/]+)(:\d+)?\/([^/]+)\/([^./]+).*/\1 \3 \4/g'
|
||||
case 'ftp*://*'
|
||||
echo $uri | sed -r 's/ftps?:\/\/([^:/]+)(:\d+)?\/([^/]+)\/([^./]+).*/\1 \3 \4/g'
|
||||
case 'ssh://*'
|
||||
echo $uri | sed -r 's/ssh:\/\/([^@]+@)?([^:/]+)(:\d+)?\/([^/]+)\/([^./]+).*/\2 \4 \5/g'
|
||||
case 'git://*'
|
||||
echo $uri | sed -r 's/git:\/\/([^:/]+)(:\d+)?\/([^/]+)\/([^./]+).*/\1 \3 \4/g'
|
||||
case '*@*'
|
||||
echo $uri | sed -r 's/([^@]+@)?([^:]+):([^/]+)\/([^./]+).*/\2 \3 \4/g'
|
||||
case '*'
|
||||
echo $uri
|
||||
return 1
|
||||
end
|
||||
return 0
|
||||
end
|
Loading…
Reference in New Issue