Skip to content

Commit

Permalink
Merge pull request #22 from utopia-php/fix-wildcard-tags
Browse files Browse the repository at this point in the history
Fix: Wildcard tags
  • Loading branch information
christyjacob4 authored Jul 29, 2024
2 parents 6ba177e + 5bffa50 commit 3084aa9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/VCS/Adapter/Git/GitHub.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ public function generateCloneCommand(string $owner, string $repositoryName, stri
break;
case self::CLONE_TYPE_TAG:
$tagName = escapeshellarg($version);
$commands[] = "git pull origin {$tagName}";
$commands[] = "git pull origin $(git ls-remote --tags origin {$tagName} | tail -n 1 | awk -F '/' '{print $3}')";
break;
}

Expand Down
35 changes: 34 additions & 1 deletion tests/VCS/Adapter/GitHubTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ public function testGenerateCloneCommand(): void
$output = '';
$resultCode = null;
\exec($gitCloneCommand, $output, $resultCode);
\var_dump($output);
$this->assertEquals(0, $resultCode);

$this->assertFileExists('/tmp/clone-branch/README.md');
Expand Down Expand Up @@ -275,6 +274,40 @@ public function testGenerateCloneCommandWithTag(): void
$this->assertEquals(0, $resultCode);

$this->assertFileExists('/tmp/clone-tag/README.md');

$gitCloneCommand = $this->vcsAdapter->generateCloneCommand('test-kh', 'test2', '0.1.*', GitHub::CLONE_TYPE_TAG, '/tmp/clone-tag2', '*');
$this->assertNotEmpty($gitCloneCommand);
$this->assertStringContainsString('sparse-checkout', $gitCloneCommand);

$output = '';
$resultCode = null;
\exec($gitCloneCommand, $output, $resultCode);
$this->assertEquals(0, $resultCode);

$this->assertFileExists('/tmp/clone-tag2/README.md');

$gitCloneCommand = $this->vcsAdapter->generateCloneCommand('test-kh', 'test2', '0.*.*', GitHub::CLONE_TYPE_TAG, '/tmp/clone-tag3', '*');
$this->assertNotEmpty($gitCloneCommand);
$this->assertStringContainsString('sparse-checkout', $gitCloneCommand);

$output = '';
$resultCode = null;
\exec($gitCloneCommand, $output, $resultCode);
$this->assertEquals(0, $resultCode);

$this->assertFileExists('/tmp/clone-tag3/README.md');


$gitCloneCommand = $this->vcsAdapter->generateCloneCommand('test-kh', 'test2', '0.2.*', GitHub::CLONE_TYPE_TAG, '/tmp/clone-tag4', '*');
$this->assertNotEmpty($gitCloneCommand);
$this->assertStringContainsString('sparse-checkout', $gitCloneCommand);

$output = '';
$resultCode = null;
\exec($gitCloneCommand, $output, $resultCode);
$this->assertNotEquals(0, $resultCode);

$this->assertFileDoesNotExist('/tmp/clone-tag4/README.md');
}

public function testUpdateComment(): void
Expand Down

0 comments on commit 3084aa9

Please sign in to comment.