From: Samuel Keeley Date: Mon, 29 Jun 2015 19:01:10 +0000 (-0700) Subject: fix for detached HEAD on git 2.4+ X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=b3cddcbd57639acbf0c4a7fa671a70f787e010da;p=puppet-vcsrepo.git fix for detached HEAD on git 2.4+ --- diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 8074950..bf11f3d 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -329,11 +329,13 @@ Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) at_path { git_with_identity('branch', '-a') }.gsub('*', ' ').split(/\n/).map { |line| line.strip } end + # git < 2.4 returns 'detached from' + # git 2.4+ returns 'HEAD detached at' # @!visibility private def on_branch? at_path { matches = git_with_identity('branch', '-a').match /\*\s+(.*)/ - matches[1] unless matches[1].match /(\(detached from|\(no branch)/ + matches[1] unless matches[1].match /(\(detached from|\(HEAD detached at|\(no branch)/ } end