phingofficial/phing

gitdescribe outputProperty spurious EOL character captured in property

Closed this issue · 0 comments

Describe the bug

  • Phing 3.0.0-RC6
  • pear/versioncontrol_git 0.5.0

When capturing most recent tag into property; the property ends with a newline character.

Note: due to time constraints, we will only accept security and other high-priority issues for the 2.x versions.

Steps To Reproduce

Actual tags:

$ git tag -l
v1.0.0
v1.0.2

cat build.xml:

<project name="bugreport" default="showBug">
    <gitdescribe repository="."
                 tags="true"
                 abbrev="4"
                 match="v*.*.*"
                 outputProperty="mostRecentTag"/>

    <target name="showBug">
        <echo msg="MostRecentTag contains: ___'${mostRecentTag}'___"/>
    </target>
</project>

Wrong result of running ./vendor/bin/phing bugreport -verbose :

[gitdescribe] git-describe: recent tags for "." repository
[gitdescribe] git-describe output: v1.0.2-1-g9823
Build sequence for target 'showBug' is: showBug
Complete build sequence is: showBug

bugreport > showBug:

Property ${mostRecentTag} => v1.0.2-1-g9823

     [echo] MostRecentTag contains: ___'v1.0.2-1-g9823
'___

BUILD FINISHED

Total time: 0.0320 seconds

Somehow [gitdescribe] git-describe output: v1.0.2-1-g9823 looks right with no additional newline added at the end of the string yet.

But the mostRecentTag property clearly has a newline at end as shown by the output:

     [echo] MostRecentTag contains: ___'v1.0.2-1-g9823
'___

It is a problem when trying to compose an archive name with the property containing the capture git tag${project.name}-${mostRecentTag}.zip.

The archive name look like this in ls -l:

ProjectName-v1.0.2-1-g9823'$'\n''.zip'

Expected behavior

It is expected that the trailing newline bet not added to the property value.

Additional notes

It is possible that the bug lies within https://github.com/pear/VersionControl_Git but there is no issue tracking in this GitHub repository.

Until this can be fixed.

A workaround solution that works is using exec directly

… and it is one less unjustified useless dependency on a dead broken piece of code that does no better than calling the git command directly, not even bringing clarity but cloaking it in a broken wrap.

I apologize for the quick mockery opinion above.

More seriously, it would be worth warning readers in the documentation that calling git is a preferred method over using pear/versioncontrol_git's dependant gitdescribe.

<exec executable="git" outputProperty="mostRecentTag">
    <arg value="describe" />
    <arg value="--tags" />
    <arg value="--abbrev=4" />
    <arg value="--match=v*.*.*" />
</exec>