1 Star 0 Fork 24

滨海IT / Snipe-IT

forked from 李小凯 / Snipe-IT 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gh-changelog.php 1.67 KB
一键复制 编辑 原始数据 按行查看 历史
snipe 提交于 2016-03-25 01:18 . Version 3 - hold onto your butts
<?php
#!/usr/bin/php -q
/* PHP requires defined timezone; GitHub uses UTC */
ini_set( 'date.timezone', 'UTC' );
/*
* YOU MUST CHANGE THESE VARIABLES
*/
$gh_user = 'snipe';
$gh_repo = 'snipe-it';
$file = 'CHANGELOG.md';
$string = 'fix|resolve|close|#changelog';
$omit = 'fuck';
/*
* No need to change anything below here
*/
// Clear old changelog info
file_put_contents($file,'');
$url = 'https://api.github.com/repos/'.$gh_user.'/'.$gh_repo.'/releases';
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
curl_setopt($ch,CURLOPT_USERAGENT,$gh_user);
$data = curl_exec($ch);
curl_close($ch);
$releases = json_decode($data, TRUE);
while( $obj = array_shift( $releases ) )
{
/* Define the beginning of each release block in the changelog */
$changelog = "\n\n### ".$obj['name']." - Released ".date("M d, Y h:i:s",strtotime($obj['created_at']))."\n";
$changelog .= $obj['prerelease'] == 'true' ? '#### This is a pre-release '."\n": '';
file_put_contents($file,$changelog,FILE_APPEND);
/* Retrieve and format each commit entry */
$gitlog = 'git log '.escapeshellarg($obj['tag_name']);
/* Set commit limit based on next tag name */
if ( $next = current($releases) )
{
$gitlog .= '...'.escapeshellarg($next['tag_name']).' ';
}
else $gitlog .= ' ';
$gitlog .= '--pretty=format:\'* <a href="http://github.com/'.$gh_user.'/'.$gh_repo.'/commit/%H">view</a> &bull;';
$gitlog .= ' %s \' --reverse | grep -i -E '.escapeshellarg($string).' ';
if ($omit!=''){
$gitlog .= ' | grep -i -E -v '.escapeshellarg($omit).'';
}
$gitlog .= '>> '.escapeshellarg($file);
exec($gitlog);
}
1
https://gitee.com/BinHaiIT2/Snipe-IT.git
git@gitee.com:BinHaiIT2/Snipe-IT.git
BinHaiIT2
Snipe-IT
Snipe-IT
master

搜索帮助