7a38fa35c404fdc17fdb4a310f73e98178c3a84a

Author
Marc Cornellà <hello@mcornella.com>
Committer
Marc Cornellà <hello@mcornella.com>
Date

Message

refactor(git-flow): extract `git-flow` completion logic

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/git-flow/_git-flow b/plugins/git-flow/_git-flow
  2new file mode 100644
  3index 0000000000000000000000000000000000000000..eab712707476a2f5b2f088e984682f2d932cae56
  4--- /dev/null
  5+++ b/plugins/git-flow/_git-flow
  6@@ -0,0 +1,327 @@
  7+#compdef git-flow
  8+
  9+_git-flow () {
 10+  local curcontext="$curcontext" state line
 11+  typeset -A opt_args
 12+
 13+  _arguments -C \
 14+    ':command:->command' \
 15+    '*::options:->options'
 16+
 17+  case $state in
 18+    (command)
 19+
 20+      local -a subcommands
 21+      subcommands=(
 22+        'init:Initialize a new git repo with support for the branching model.'
 23+        'feature:Manage your feature branches.'
 24+        'release:Manage your release branches.'
 25+        'hotfix:Manage your hotfix branches.'
 26+        'support:Manage your support branches.'
 27+        'version:Shows version information.'
 28+      )
 29+      _describe -t commands 'git flow' subcommands
 30+    ;;
 31+
 32+    (options)
 33+      case $line[1] in
 34+
 35+        (init)
 36+          _arguments \
 37+            -f'[Force setting of gitflow branches, even if already configured]'
 38+          ;;
 39+
 40+          (version)
 41+          ;;
 42+
 43+          (hotfix)
 44+            __git-flow-hotfix
 45+          ;;
 46+
 47+          (release)
 48+            __git-flow-release
 49+          ;;
 50+
 51+          (feature)
 52+            __git-flow-feature
 53+          ;;
 54+      esac
 55+    ;;
 56+  esac
 57+}
 58+
 59+__git-flow-release () {
 60+  local curcontext="$curcontext" state line
 61+  typeset -A opt_args
 62+
 63+  _arguments -C \
 64+    ':command:->command' \
 65+    '*::options:->options'
 66+
 67+  case $state in
 68+    (command)
 69+
 70+      local -a subcommands
 71+      subcommands=(
 72+        'start:Start a new release branch.'
 73+        'finish:Finish a release branch.'
 74+        'list:List all your release branches. (Alias to `git flow release`)'
 75+        'publish: public'
 76+        'track: track'
 77+      )
 78+      _describe -t commands 'git flow release' subcommands
 79+      _arguments \
 80+        -v'[Verbose (more) output]'
 81+    ;;
 82+
 83+    (options)
 84+      case $line[1] in
 85+
 86+        (start)
 87+          _arguments \
 88+            -F'[Fetch from origin before performing finish]'\
 89+            ':version:__git_flow_version_list'
 90+        ;;
 91+
 92+        (finish)
 93+          _arguments \
 94+            -F'[Fetch from origin before performing finish]' \
 95+            -s'[Sign the release tag cryptographically]'\
 96+            -u'[Use the given GPG-key for the digital signature (implies -s)]'\
 97+            -m'[Use the given tag message]'\
 98+            -p'[Push to $ORIGIN after performing finish]'\
 99+            -k'[Keep branch after performing finish]'\
100+            -n"[Don't tag this release]"\
101+            ':version:__git_flow_version_list'
102+        ;;
103+
104+        (publish)
105+          _arguments \
106diff --git a/plugins/git-flow/git-flow.plugin.zsh b/plugins/git-flow/git-flow.plugin.zsh
107index 041df3aa5185370fbadf49c62e6afc40ac18e0a4..13399aaa392c74607db270ab97b0131221fb7788 100644
108--- a/plugins/git-flow/git-flow.plugin.zsh
109+++ b/plugins/git-flow/git-flow.plugin.zsh
110@@ -1,26 +1,4 @@
111-#!zsh
112-#
113-# Installation
114-# ------------
115-#
116-# To achieve git-flow completion nirvana:
117-#
118-#  0. Update your zsh's git-completion module to the newest version.
119-#     From here. https://raw.githubusercontent.com/zsh-users/zsh/master/Completion/Unix/Command/_git
120-#
121-#  1. Install this file. Either:
122-#
123-#     a. Place it in your .zshrc:
124-#
125-#     b. Or, copy it somewhere (e.g. ~/.git-flow-completion.zsh) and put the following line in
126-#        your .zshrc:
127-#
128-#            source ~/.git-flow-completion.zsh
129-#
130-#     c. Or, use this file as an oh-my-zsh plugin.
131-#
132-
133-#Alias
134+# Aliases
135 alias gfl='git flow'
136 alias gfli='git flow init'
137 alias gcd='git checkout $(git config gitflow.branch.develop)'
138@@ -44,330 +22,9 @@ alias gflfpc='git flow feature publish $(echo $(current_branch) | cut -c 9-)'
139 alias gflrfc='git flow release finish $(echo $(current_branch) | cut -c 9-)'
140 alias gflrpc='git flow release publish $(echo $(current_branch) | cut -c 9-)'
141 
142-_git-flow ()
143-{
144-	local curcontext="$curcontext" state line
145-	typeset -A opt_args
146-
147-	_arguments -C \
148-		':command:->command' \
149-		'*::options:->options'
150-
151-	case $state in
152-		(command)
153-
154-			local -a subcommands
155-			subcommands=(
156-				'init:Initialize a new git repo with support for the branching model.'
157-				'feature:Manage your feature branches.'
158-				'release:Manage your release branches.'
159-				'hotfix:Manage your hotfix branches.'
160-				'support:Manage your support branches.'
161-				'version:Shows version information.'
162-			)
163-			_describe -t commands 'git flow' subcommands
164-		;;
165-
166-		(options)
167-			case $line[1] in
168-
169-				(init)
170-					_arguments \
171-						-f'[Force setting of gitflow branches, even if already configured]'
172-					;;
173-
174-					(version)
175-					;;
176-
177-					(hotfix)
178-						__git-flow-hotfix
179-					;;
180-
181-					(release)
182-						__git-flow-release
183-					;;
184-
185-					(feature)
186-						__git-flow-feature
187-					;;
188-			esac
189-		;;
190-	esac
191-}
192-
193-__git-flow-release ()
194-{
195-	local curcontext="$curcontext" state line
196-	typeset -A opt_args
197-
198-	_arguments -C \
199-		':command:->command' \
200-		'*::options:->options'
201-
202-	case $state in
203-		(command)
204-
205-			local -a subcommands
206-			subcommands=(
207-				'start:Start a new release branch.'
208-				'finish:Finish a release branch.'
209-				'list:List all your release branches. (Alias to `git flow release`)'