Skip to content

Commit

Permalink
refactor: fish autoload-compliant
Browse files Browse the repository at this point in the history
  • Loading branch information
joseluisq committed Nov 24, 2023
1 parent 5dab658 commit ce17ab2
Show file tree
Hide file tree
Showing 31 changed files with 356 additions and 326 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.gitnow
**/.DS_Store
80 changes: 0 additions & 80 deletions completions/__gitnow_completions.fish

This file was deleted.

20 changes: 20 additions & 0 deletions completions/merge.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# GitNow — Speed up your Git workflow. 🐠
# https://github.com/joseluisq/gitnow

# Merge command

__gitnow_load_git_functions

complete -f -x -c merge -a '(__fish_git_branches)'

complete -f -x -c merge \
-s h -l help \
-d "Show information about the options for this command"

complete -f -x -c merge \
-s a -l abort \
-d "Abort conflicted merge"

complete -f -x -c merge \
-s c -l continue \
-d "Continue merge"
26 changes: 26 additions & 0 deletions completions/move.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# GitNow — Speed up your Git workflow. 🐠
# https://github.com/joseluisq/gitnow

# Move command

__gitnow_load_git_functions

complete -f -x -c move -a '(__fish_git_branches)'

complete -f -x -c move \
-s h -l help \
-d "Show information about the options for this command"

complete -f -x -c move \
-s p -l prev \
-d "Switch to a previous branch using the `--no-apply-stash` option (equivalent to \"move -\")"

complete -f -x -c move \
-s n -l no-apply-stash \
-a '(__fish_git_branches)' \
-d "Switch to a local branch but without applying current stash"

complete -f -x -c move \
-s u -l upstream \
-a '(__fish_git_branches)' \
-d "Fetch a remote branch and switch to it applying current stash"
31 changes: 31 additions & 0 deletions completions/tag.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# GitNow — Speed up your Git workflow. 🐠
# https://github.com/joseluisq/gitnow

# Tag command

__gitnow_load_git_functions

complete -f -x -c tag \
-d "List all tags in a lexicographic order and treating tag names as versions"

complete -f -x -c tag -a '(__fish_git_tags)'

complete -f -x -c tag \
-s h -l help \
-d "Show information about the options for this command"

complete -f -x -c tag \
-s l -l latest \
-d "Show only the latest Semver release tag version (no suffixed ones or others)"

complete -f -x -c tag \
-s x -l major \
-d "Tag auto-incrementing a major version number"

complete -f -x -c tag \
-s y -l minor \
-d "Tag auto-incrementing a minor version number"

complete -f -x -c tag \
-s z -l patch \
-d "Tag auto-incrementing a patch version number"
18 changes: 18 additions & 0 deletions conf.d/gitnow.fish
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
# GitNow — Speed up your Git workflow. 🐠
# https://github.com/joseluisq/gitnow

set -g gitnow_version 2.11.0

# Default global variables
set -q GITNOW_CONFIG_FILE; or set -g GITNOW_CONFIG_FILE ~/.gitnow
set -g gitnow_commands 'all' 'assume' 'bitbucket' 'bugfix' 'commit' 'commit-all' 'feature' 'github' 'gitnow' 'hotfix' 'logs' 'merge' 'move' 'pull' 'push' 'release' 'show' 'stage' 'state' 'tag' 'unstage' 'untracked' 'upstream'

if set -q __fish_config_dir
set -g fish_config "$__fish_config_dir"
else
set -q XDG_CONFIG_HOME
and set -g fish_config "$XDG_CONFIG_HOME/fish"
or set -g fish_config "~/.config/fish"
end

set -q fish_snippets; or set -g fish_snippets "$fish_config/conf.d"

__gitnow_load_config

# Other specific global variables
set -g g_current_branch

function __gitnow_install -e gitnow_install
Expand Down
32 changes: 0 additions & 32 deletions conf.d/gitnow_config.fish

This file was deleted.

20 changes: 20 additions & 0 deletions functions/__gitnow_check_if_branch_exist.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# GitNow — Speed up your Git workflow. 🐠
# https://github.com/joseluisq/gitnow

function __gitnow_check_if_branch_exist
set -l xfound 0

if test (count $argv) -eq 1
set -l xbranch $argv[1]
set -l xbranch_list (__gitnow_current_branch_list)

for b in $xbranch_list
if [ "$xbranch" = "$b" ]
set xfound 1
break
end
end
end

echo $xfound
end
17 changes: 17 additions & 0 deletions functions/__gitnow_clone_msg.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# GitNow — Speed up your Git workflow. 🐠
# https://github.com/joseluisq/gitnow

function __gitnow_clone_msg
set -l msg $argv[1]

echo "Repository name is required!"
echo "Example: $msg your-repo-name"
echo "Usages:"
echo " a) $msg username/repo-name"
echo " b) $msg username repo-name"
echo " c) $msg repo-name"
echo " For this, it's necessary to set your $msg username (login)"
echo " to global config before like: "
echo " git config --global user.$msg \"your-username\""
echo
end
18 changes: 18 additions & 0 deletions functions/__gitnow_clone_params.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# GitNow — Speed up your Git workflow. 🐠
# https://github.com/joseluisq/gitnow

function __gitnow_clone_params
set -l repo

if count $argv >/dev/null
if test (count $argv) -gt 1
set repo $argv[1]/$argv[2]
else if echo $argv | LC_ALL=C command grep -q -E '^([a-zA-Z0-9\_\-]+)\/([a-zA-Z0-9\_\-]+)$'
set repo $argv
else
set repo "%S/$argv"
end
end

echo $repo
end
41 changes: 41 additions & 0 deletions functions/__gitnow_clone_repo.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# GitNow — Speed up your Git workflow. 🐠
# https://github.com/joseluisq/gitnow

function __gitnow_clone_repo
set -l repo $argv[1]
set -l platform $argv[2]

if test -n "$repo"
set -l ok 1

if echo $repo | LC_ALL=C command grep -q -E '^[\%S].+'
set -l user (command git config --global user.$platform)

if test -n "$user"
set -l repor (echo $repo | LC_ALL=C command sed -e "s/^%S/$user/")
set repo $repor
else
set ok 0
end
end

if test $ok -eq 1
if [ "$platform" = "github" ]
set url github.com
end

if [ "$platform" = "bitbucket" ]
set url bitbucket.org
end

set -l repo_url git@$url:$repo.git

echo "📦 Remote repository: $repo_url"
command git clone $repo_url
else
__gitnow_clone_msg $platform
end
else
__gitnow_clone_msg $platform
end
end
6 changes: 6 additions & 0 deletions functions/__gitnow_current_branch_list.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# GitNow — Speed up your Git workflow. 🐠
# https://github.com/joseluisq/gitnow

function __gitnow_current_branch_list
command git branch --list --no-color | LC_ALL=C command sed -E "s/^(\*?[ \t]*)//g" 2>/dev/null
end
6 changes: 6 additions & 0 deletions functions/__gitnow_current_branch_name.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# GitNow — Speed up your Git workflow. 🐠
# https://github.com/joseluisq/gitnow

function __gitnow_current_branch_name
command git symbolic-ref --short HEAD 2>/dev/null
end
7 changes: 7 additions & 0 deletions functions/__gitnow_current_remote.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# GitNow — Speed up your Git workflow. 🐠
# https://github.com/joseluisq/gitnow

function __gitnow_current_remote
set -l branch_name (__gitnow_current_branch_name)
command git config "branch.$branch_name.remote" 2>/dev/null; or echo origin
end
Loading

0 comments on commit ce17ab2

Please sign in to comment.