代码拉取完成,页面将自动刷新
<html>
<head>
<meta charset="utf-8">
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.js"></script>
</head>
<body>
<h1>GitLab周报小工具</h1>
GitLib域名/IP;<input id='git_lab_base_url' value="gitlab.jishudao.com"/><br/>
项目ID;<input id='git_lab_project_id' value="520"/><br/>
GitLib密钥;<input id='git_lab_private_token' value="woewo_eiewoequoewqo_xr"/><br/>
开始时间:<input id='startTime' value="2018-12-10T0:00:00.000+08:00"/><br/>
结束时间:<input id='endTime' value="2018-12-14T23:00:00.000+08:00"/><br/>
用户名:<input id='author_name' value="zhongdaiqi"/><br/>
<button id="report_btn">生成</button><br/>
<textarea id="report" style="width:100%;height:500px;"></textarea>
<script>
var private_token = 'woewo_eiewoequoewqo_xr';//在GitLab后台找到private token; you can find private toke from the setting page on gitlab
var per_page = 1000000; // I have not find the better way to fetch all commit.
var gitliburl=`http://gitlab.jishudao.com/api/v3/projects/520/repository/commits?private_token=${private_token}&per_page=${per_page}&t=`+new Date().getTime();
var start_time = '2018-12-10T0:00:00.000+08:00';
var end_time = '2018-12-14T23:00:00.000+08:00';
$.getJSON(gitliburl,function(commitlist){
//console.log(commitlist);
for(var k in commitlist){
//console.log(commitlist[k]);
var commit = commitlist[k];
if(commit.author_name=='zhongdaiqi' && commit.created_at>start_time && commit.created_at < end_time){
console.log(commit.created_at+" "+commit.message);
}
}
});
//其实直接F12玩起来就好,这个提供为懒人使用
$("#report_btn").click(function(){
var git_lab_base_url = $("#git_lab_base_url").val();
var git_lab_project_id = $("#git_lab_project_id").val();
var git_lab_private_token = $("#git_lab_private_token").val();
var gitliburl = `http://${git_lab_base_url}/api/v3/projects/${git_lab_project_id}/repository/commits?private_token=${git_lab_private_token}&per_page=${per_page}&t=`+new Date().getTime();
console.log(gitliburl);
$.getJSON(gitliburl,function(commitlist){
console.log(commitlist);
var start_time = $("#startTime").val();
var end_time = $("#endTime").val();
var author_name = $("#author_name").val();
console.log(start_time);
console.log(end_time);
var report_str = "尊敬的领导,本周主要完成了以下工作项:\r\n";
for(var k in commitlist){
//console.log(commitlist[k]);
var commit = commitlist[k];
if(commit.author_name== author_name && commit.created_at>start_time && commit.created_at < end_time){
report_str = report_str+ commit.created_at.split("T")[0]+" "+commit.message +"";
}
}
$("#report").val(report_str);
});
});
</script>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。