Skip to content

Code Improvements #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 1, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add 'git_version' function
- Avoid updating the application version in future releases
  • Loading branch information
joaorobertopb committed May 31, 2018
commit c16143992613186a0d0793b6c327ee3e545288b0
2 changes: 1 addition & 1 deletion cghooks
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use BrainMaestro\GitHooks\Commands\ListCommand;
use BrainMaestro\GitHooks\Commands\HookCommand;
use Symfony\Component\Console\Application;

$application = new Application('Composer Git Hooks', 'v2.2.0');
$application = new Application('Composer Git Hooks', git_version());

$hooks = Hook::getValidHooks($dir);
$application->add(new AddCommand($hooks));
Expand Down
17 changes: 17 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Symfony\Component\Process\Process;

if (! function_exists('windows_os')) {
/**
* Determine whether the current environment is Windows based.
Expand Down Expand Up @@ -29,3 +31,18 @@ function mkdir_if_not_exist($dir, $mode = 0700, $recursive = true)
}
}
}

if (! function_exists('git_version')) {
/**
* Get latest git tag version.
*
* @return string
*/
function git_version()
{
$process = new Process('git describe --tags $(git rev-list --tags --max-count=1)');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now requires symfony/process as a project dependancy, right?

$process->run();

return trim($process->getOutput()) ?: 'unreleased';
}
}