Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
O
oh-my-fish
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
oh-my-fish
Commits
c20ff54a
Commit
c20ff54a
authored
Apr 13, 2016
by
Itzik Ephraim
Committed by
Pablo Santiago Blum de Aguiar
Oct 03, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
doctor: check if Git remotes match db URLs
Co-authored-by:
Pablo Santiago Blum de Aguiar
<
scorphus@gmail.com
>
parent
90f875e0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
0 deletions
+83
-0
pkg/omf/functions/core/omf.doctor.fish
pkg/omf/functions/core/omf.doctor.fish
+47
-0
pkg/omf/functions/repo/omf.repo.remote_uri.fish
pkg/omf/functions/repo/omf.repo.remote_uri.fish
+13
-0
pkg/omf/functions/repo/omf.repo.uri_components.fish
pkg/omf/functions/repo/omf.repo.uri_components.fish
+23
-0
No files found.
pkg/omf/functions/core/omf.doctor.fish
View file @
c20ff54a
...
...
@@ -45,6 +45,52 @@ function __omf.doctor.git_version
end
end
function __omf.doctor.remote_match_db -a pkg_path
if test -z "$pkg_path"
# No package specified, run test for all packages
omf.index.update
set -l check_result 0
for pkg_path in $OMF_PATH/{themes,pkg}/*
__omf.doctor.remote_match_db $pkg_path
set check_result (math $check_result + $status)
end
return $check_result
end
# Check if the package remote matches the package repository
set -l path_parts
begin
set -l IFS '/'
echo $pkg_path | read -a path_parts
end
set -l pkg_name $path_parts[-1]
set -l index_uri (omf.index.stat $pkg_name repository)
or begin
# Built-in 'omf' and 'fish-spec' are exempt from this check
contains -- $pkg_name omf fish-spec; and return 0
echo (omf::err)"Warning:"(omf::off) "No index entry for "(omf::em)$pkg_name(omf::off)"."
echo
return 1
end
set -l repo_uri (omf.repo.remote_uri "$pkg_path")
set -l db_canonical (omf.repo.uri_components $index_uri)
set -l repo_canonical (omf.repo.uri_components $repo_uri)
if test "$db_canonical" != "$repo_canonical"
echo (omf::err)"Warning:"(omf::off) "The remote URI for "(omf::em)"$pkg_name"(omf::off)" doesn't match the URI in OMF's database."
echo "Remote URI:" $repo_uri
echo "Index URI:" $index_uri
echo
return 1
end
return 0
end
function omf.doctor
echo "Oh My Fish version: "(omf.version)
echo "OS type: "(uname)
...
...
@@ -55,6 +101,7 @@ function omf.doctor
__omf.doctor.fish_version; or set -l doctor_failed
__omf.doctor.git_version; or set -l doctor_failed
__omf.doctor.theme; or set -l doctor_failed
__omf.doctor.remote_match_db; or set -l doctor_failed
fish "$OMF_PATH/bin/install" --check
or set -l doctor_failed
...
...
pkg/omf/functions/repo/omf.repo.remote_uri.fish
0 → 100644
View file @
c20ff54a
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
pkg/omf/functions/repo/omf.repo.uri_components.fish
0 → 100644
View file @
c20ff54a
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment