visionmedia / deploy

Minimalistic deployment shell script
1.15k stars 137 forks source link

git for-each-ref fails in zsh #23

Open joews opened 10 years ago

joews commented 10 years ago

Hello,

The execution of for-each-ref fails when the target machine uses zsh (or csh) as its default shell.

deploy.conf

[production]
user joe
host localhost
repo git@github.com:jwhitfieldseed/deploy-test.git
path /tmp/deploy-test/production

Output from deploy where the target machine uses zsh:

~/code/deploy-test develop  
❯ deploy production
  ○ deploying
  ○ hook pre-deploy
  ○ fetching updates
Fetching origin
From github.com:jwhitfieldseed/deploy-test
   c8a0d31..88cb561  master     -> origin/master
   b7a1fb2..f404710  develop    -> origin/develop
 * [new tag]         moose4     -> moose4
From github.com:jwhitfieldseed/deploy-test
 * [new tag]         moose      -> moose
 * [new tag]         moose2     -> moose2
 * [new tag]         moose3     -> moose3
  ○ fetching latest tag
zsh:1: no matches found: --sort=-*authordate
  ○ resetting HEAD to
HEAD is now at c8a0d31 Merge branches 'develop' and 'master' of github.com:jwhitfieldseed/deploy-test
  ○ hook post-deploy
  ○ hook test
  ○ successfully deployed

Output of running that command in isolation on each of the shells on my machine (running Mavericks):

❯ zsh

~/code/deploy-test develop  
❯ git for-each-ref refs/tags \ 
      --sort=-*authordate \
      --format='%(refname)' \
      --count=1 | cut -d '/' -f 3
zsh: no matches found: --sort=-*authordate

~/code/deploy-test develop  

❯ bash
joe deploy-test $ git for-each-ref refs/tags \
>       --sort=-*authordate \
>       --format='%(refname)' \
>       --count=1 | cut -d '/' -f 3
moose4
joe deploy-test $ exit

~/code/deploy-test develop  
❯ sh
sh-3.2$ git for-each-ref refs/tags \
>       --sort=-*authordate \
>       --format='%(refname)' \
>       --count=1 | cut -d '/' -f 3
moose4
sh-3.2$ exit

~/code/deploy-test develop  
❯ ksh
$ 
me)' \
      --count=1 | cut -d '/' -f 3> 
me)' \
      --count=1 | cut -d '/' -f 3>       --format='%(refna
>       --count=1 | cut -d '/' -f 3
moose4
$ 

~/code/deploy-test develop  
❯ csh
[Joes-MacBook-Pro:~/code/deploy-test] joe% git for-each-ref refs/tags \
      --sort=-*authordate \
      --format='%(refname)' \
      --count=1 | cut -d '/' -f 3?       --sort=-*authordate \
?       --format='%(refname)' \
?       --count=1 | cut -d '/' -f 3
git: No match.

I don't know enough about the way each shell escapes newlines to have a quick fix (besides forcing bash on the target machine, which may not be so bad given that the deploy script itself is bash). Does anybody else have one? If not I am happy to look into it for a fix.

joews commented 10 years ago

Hmm, my terminal mangled the command in ksh, but the output worked. Also can't remember why my tags are moose-based.

niftylettuce commented 10 years ago

Surround -*authordate with apostrophes and it fixes issue?