From a57d60e1b43256baa40f23bec321220d08394a40 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 16 Apr 2024 23:04:42 +0100 Subject: [PATCH] Fix GitLab and Bitbucket URLs Remove GitLab and Bitbucket URLs when getting the user and repo name. --- lib/shared/modules/zsh.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/shared/modules/zsh.nix b/lib/shared/modules/zsh.nix index 6e784963..6b5b8bc3 100644 --- a/lib/shared/modules/zsh.nix +++ b/lib/shared/modules/zsh.nix @@ -11,10 +11,15 @@ clone() { repo_url="$1" - # TODO: work with Bitbucket and GitLab. + # TODO: make it work with multi-level URLS - e.g. https://gitlab.com/a/b/c/d.git - user_and_repo_name="''${repo_url#https://github.com/}" - user_and_repo_name="''${repo_url#git@github.com:}" + user_and_repo_name="''${repo_url}" + user_and_repo_name="''${user_and_repo_name#git@bitbucket.com:}" + user_and_repo_name="''${user_and_repo_name#git@github.com:}" + user_and_repo_name="''${user_and_repo_name#git@gitlab.com:}" + user_and_repo_name="''${user_and_repo_name#https://bitbucket.com/}" + user_and_repo_name="''${user_and_repo_name#https://github.com/}" + user_and_repo_name="''${user_and_repo_name#https://gitlab.com/}" if [[ "''${user_and_repo_name}" =~ / ]]; then user="''${user_and_repo_name%%/*}"