GIT打差量包
git diff master --name-only | xargs tar -cvf update.tar.gz
删除过期分支
shell脚本查找过期分支
#!/bin/sh
git_path=F:/git/web
cd $git_path
git for-each-ref --sort=committerdate --format='%(refname:short) * %(authorname) * %(committerdate:relative)' refs/remotes/ | column -t -s '*' >f:/autoweb.txt
curl http://127.0.0.1:88/git/indexweb
if [[ $1 == "del" ]];then
cat f:/autoweb_out.txt | while read line
do
echo "git push origin --delete $line"
done
fi
echo '[----------------------success done----------------------]'
php脚本给团队成员发邮件通知
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
use Nette\Mail\Message;
class Git extends CI_Controller
{
public function indexweb()
{
$txt = "F:/autoweb.txt";
$file = fopen($txt, "r") or exit("无法打开文件!");;
$txt_out = "F:/autoweb_out.txt";
$arr = [
'who1' => [],
'who2' => [],
];
if ($file) {
while (!feof($file)) {
$buffer = fgets($file);
if (preg_match('/(feature|test|release)/', $buffer)) {
foreach ($arr as $k => &$v) {
if (preg_match('/[2-9]\s(month|weeks)/', $buffer)) {
if (preg_match('/\s' . $k . '\s/', $buffer)) {
array_push($v, $buffer);
}
}
}
}
if (preg_match('/hotfix/', $buffer)) {
foreach ($arr as $k => &$v) {
if (preg_match('/([4-9]\s(days))|([2-9]\s(month|weeks))/', $buffer)) {
if (preg_match('/\s' . $k . '\s/', $buffer)) {
array_push($v, $buffer);
}
}
}
}
}
}
$html = "";
$handler_write = fopen($txt_out, 'w');
foreach ($arr as $key => &$value) {
$table = '';
$tips = '请各自确认自己可以删除的分支,执行以下远端分支删除命令:<br>';
if (!empty($value)) {
$table .= '<table border="1" cellspacing="0">';
foreach ($value as $vv) {
preg_match('/(\S+)\s+(\S+)\s+(.*)/', $vv, $result);
$table .= '<tr><td>' . $result[1] . '</td><td>' . $result[2] . '</td><td>' . $result[3] . '</td></tr>';
preg_match('/origin\/(.*)/', $result[1], $write_line);
fwrite($handler_write, $write_line[1] . "\r\n");
$tips .= 'git push origin --delete ' . $write_line[1] . '<br>';
}
$table .= '</table>';
$value = $table;
$html .= '<h1>' . $key . ':</h1><br>' . $value . '<br>' . $tips;
}
}
fclose($handler_write);
$mail = new Message;
$mail->setFrom('xx@xx.com')
->addTo('xx1@xx1.com')
->setSubject('即将删除以下过期WEB远端分支,请核对')->setHtmlBody($html);
$mailer = new Nette\Mail\SmtpMailer(
[
'host' => 'smtp.ym.163.com',
'username' => 'xx@xx.com',
'password' => 'yyy'
]
);
if (!empty($mail)) {
$mailer->send($mail);
}
}
}
作者
admin
发表于
2014-09-19 13:45:36
,添加在分类
工具
下
,并被添加「
工具
」标签
,最后修改于
2018-02-24 17:21:12
Comments