Skip to content

Commit

Permalink
Fix #1814 Trim EOL in setProperty from command output (#1815)
Browse files Browse the repository at this point in the history
* Fix #1814 Trim EOL in setProperty from command output

* Fix(GitTagTaskTest): Wrong value in assertPropertyEquals

It was wrongly asserted that the outputProperty would contain
a newline character `\n`.
Ironically this test was written wrong to accomodate the bugged
capture of a newline at end of property value;
(which is the exact purpose of the fix in #1815)
  • Loading branch information
lea-BMS authored Apr 26, 2024
1 parent 8dc3e91 commit 5ce8dfe
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Phing/Task/Ext/Git/GitDescribeTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function main()
}

if (null !== $this->outputProperty) {
$this->project->setProperty($this->outputProperty, $output);
$this->project->setProperty($this->outputProperty, trim($output));
}

$this->log(
Expand Down
2 changes: 1 addition & 1 deletion src/Phing/Task/Ext/Git/GitTagTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public function main()
}

if (null !== $this->outputProperty) {
$this->project->setProperty($this->outputProperty, $output);
$this->project->setProperty($this->outputProperty, trim($output));
}

$this->log(
Expand Down
2 changes: 1 addition & 1 deletion tests/Phing/Test/Task/Ext/Git/GitTagTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function testTagOutputPropertySet(): void
$this->assertInLogs('git-tag command: LC_ALL=C && git tag \'marked\'');
$this->assertInLogs('git-tag command: LC_ALL=C && git tag -l \'marked\'');
$this->assertInLogs('git-tag output: marked');
$this->assertPropertyEquals('gitLogOutput', 'marked' . "\n");
$this->assertPropertyEquals('gitLogOutput', 'marked');
}

public function testTagWithCommitSet(): void
Expand Down

0 comments on commit 5ce8dfe

Please sign in to comment.