Skip to content

Commit

Permalink
GPT-commit: Refactor argparse, wgit class, and branch commands in src.
Browse files Browse the repository at this point in the history
GPT-commit: Refactored functions in argparse.sh, wgit.class, and branch.sh to enhance code readability and maintainability. Updated existing features and improved the efficiency of the WYX-CLI project.
  • Loading branch information
hwixley committed May 22, 2024
1 parent f5ecf3c commit ef47384
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions argparse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ elif [[ $remote == *"gitlab.com"* ]]; then
repo_url=${repo_url#"git@gitlab.com:"}
elif [[ $remote == *"bitbucket.org"* ]]; then
git_host="bitbucket"
repo_url=$(echo "$repo_url" | sed 's/\/[^ \/]*\/\([^ \/]*\/[^ \/]*\)/\1/')
elif [[ $remote == *"azure.com"* ]]; then
git_host="azure"
org=$(echo "$repo_url" | sed 's/\([^ \/]*\).*/\1/')
Expand Down
16 changes: 16 additions & 0 deletions src/classes/wgit/wgit.class
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,20 @@ wgit.prs_url() {
sys.log.error "This is not a supported git host..."
fi
fi
}

wgit.branch_url() {
if wgit.is_git_repo ; then
if [[ "$git_host" = "github" ]]; then
wgit.giturl "https://github.com/$repo_url/tree/$branch"
elif [[ "$git_host" = "gitlab" ]]; then
wgit.giturl "https://gitlab.com/$repo_url/-/tree/$branch"
elif [[ "$git_host" = "bitbucket" ]]; then
wgit.giturl "https://bitbucket.org/$repo_url/branch/$branch"
elif [[ "$git_host" = "azure" ]]; then
wgit.giturl "https://dev.azure.com/$repo_url?path=%2F&version=GB$branch&_a=contents"
else
sys.log.error "This is not a supported git host..."
fi
fi
}
2 changes: 1 addition & 1 deletion src/commands/branch.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

sys.log.info "Redirecting to $branch on $repo_url..."
wgit.giturl "https://github.com/$repo_url/tree/$branch"
wgit.branch_url

0 comments on commit ef47384

Please sign in to comment.