Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git for-each-ref fails in zsh #23

Open
joews opened this issue Jul 16, 2014 · 2 comments
Open

git for-each-ref fails in zsh #23

joews opened this issue Jul 16, 2014 · 2 comments

Comments

@joews
Copy link

joews commented Jul 16, 2014

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 [email protected]: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
Copy link
Author

joews commented Jul 16, 2014

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

@niftylettuce
Copy link

Surround -*authordate with apostrophes and it fixes issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants