Skip to content

Commit

Permalink
fix: add git remote repository url format check
Browse files Browse the repository at this point in the history
  • Loading branch information
marcocesarato committed May 14, 2021
1 parent eebfbea commit 56aff63
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
16 changes: 15 additions & 1 deletion src/DefaultCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,21 @@ protected function execute(InputInterface $input, OutputInterface $output)

return 1; //Command::FAILURE;
}
$this->validRequirement('Valid git repository detected');
$this->validRequirement('Valid git worktree detected');

// Check git repository
if (empty(Repository::parseRemoteUrl())) {
$url = Repository::getRemoteUrl();
$output->error(
'The remote url of your git repository ("' . $url . '") not been parsed correctly. ' .
'Please open and issue including your repository url format to make it compatible with this tool: ' .
"\nhttps://github.com/marcocesarato/php-conventional-changelog/issues"
);

return 1; //Command::FAILURE;
}
$this->validRequirement('Valid git remote repository url');

$this->outputStyle->newLine();

// Initialize changelog
Expand Down
4 changes: 2 additions & 2 deletions src/Git/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ protected static function parseShortcodes($content, $shortcodes)
/**
* Parse remote url.
*
* @return array|false
* @return array
*/
public static function parseRemoteUrl()
{
Expand All @@ -253,6 +253,6 @@ public static function parseRemoteUrl()
}
}

return false;
return [];
}
}

0 comments on commit 56aff63

Please sign in to comment.