Skip to content

Commit

Permalink
removed old bumping
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed Aug 1, 2016
1 parent 368e810 commit 347befd
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 518 deletions.
3 changes: 0 additions & 3 deletions src/config/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@
'.gitignore' => [
'class' => 'hidev\controllers\GitignoreController',
],
'CHANGELOG.md' => [
'class' => 'hidev\controllers\ChangelogController',
],
],
'view' => [
'class' => 'hidev\base\View',
Expand Down
22 changes: 0 additions & 22 deletions src/controllers/ChangelogController.php

This file was deleted.

70 changes: 0 additions & 70 deletions src/controllers/CommitsController.php

This file was deleted.

102 changes: 1 addition & 101 deletions src/controllers/GitController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,106 +20,11 @@ class GitController extends VcsController
{
protected $_before = ['.gitignore'];

/**
* @var array VCS tags
*/
protected $_tags = [];

public function getTags()
{
return $this->_tags;
}

public function loadTags()
{
exec("git log --date=short --tags --simplify-by-decoration --pretty='format:%cd %d'", $logs);
foreach ($logs as $log) {
preg_match('/^([0-9-]+)\s*(\(.*\))?$/', $log, $m);
$this->_tags[$this->matchTag($m[2]) ?: $this->initTag] = $m[1];
}
}

/**
* @var string current tag
*/
protected $tag;

/**
* @var array VCS history
*/
protected $_history = [];

/**
* @var array all the commits
*/
protected $_commits = [];

public function getCommits()
{
return $this->_commits;
}

public function getHistory()
{
return $this->_history;
}

public function addHistory($commit)
{
$this->tag = $this->matchTag($commit['tag']) ?: $this->tag;
$commit['tag'] = $this->tag;
$hash = (string) $commit['hash'];
$this->_commits[$hash] = $commit;
$this->_history[$this->tag][$hash] = $commit;
}

/**
* Loads raw git history.
* @throws InvalidConfigException
*/
public function loadHistory()
{
if (!file_exists('.git')) {
return;
}
exec("git log --date=short --pretty='format:%h %ad %ae %s |%d'", $logs);
$this->tag = $this->lastTag;
if (empty($logs)) {
return;
}
foreach ($logs as $log) {
if (!preg_match('/^(\w+) ([0-9-]+) (\S+) (.*?)\s+\| ?(\([^\(\)]+\))?$/', $log, $m)) {
throw new InvalidConfigException('failed parse git log');
}
$this->addHistory([
'hash' => $m[1],
'date' => $m[2],
'email' => $m[3],
'comment' => $m[4],
'tag' => $m[5],
]);
}
}

public function matchTag($str)
{
preg_match('/^\((.*?)\)$/', $str, $m);
$refs = explode(', ', $m[1]);
foreach ($refs as $ref) {
if (preg_match('/^tag: (.*)$/', $ref, $m)) {
return $m[1];
}
}

return false;
}

public function actionLoad()
{
$this->loadTags();
$this->loadHistory();
}

public function actionRelease($version = null)
{
$version = $this->takeGoal('version')->getVersion($version);
Expand Down Expand Up @@ -151,12 +56,7 @@ public function getUserEmail()

public function getYear()
{
$tags = $this->getTags();
if (empty($tags)) {
$date = `git log --reverse --pretty=%ai | head -n 1`;
} else {
$date = array_pop($tags);
}
$date = `git log --reverse --pretty=%ai | head -n 1`;
$year = $date ? date('Y', strtotime($date)) : '';

return $year;
Expand Down
4 changes: 0 additions & 4 deletions src/controllers/VcsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
*/
class VcsController extends CommonController
{
public $lastTag = 'Under development';

public $initTag = 'Development started';

protected $_ignore;

public function setIgnore($items, $where = '')
Expand Down
44 changes: 0 additions & 44 deletions src/handlers/ChangelogHandler.php

This file was deleted.

Loading

0 comments on commit 347befd

Please sign in to comment.