11 Commits
Author | SHA1 | Message | Date |
---|---|---|---|
|
5d2285ac8b |
fix
|
5 years ago |
|
bf07d7c470 |
自动弹出流程申请单
|
5 years ago |
|
0542bc7102 |
fix
|
5 years ago |
|
a7e4df094f |
fix
|
5 years ago |
|
66821cf3a4 |
通知
|
5 years ago |
|
f6d5e61c6c |
添加任务
|
5 years ago |
|
db6e6a2368 |
添加文档
|
5 years ago |
|
db815358cb |
同步分支中的评论
|
5 years ago |
|
8e79e37958 |
fix
|
5 years ago |
|
4bff00b1ea |
Merge branch 'master' of https://git.ouxuan.net/3136352472/ouxuan.oa
|
5 years ago |
|
acf6470e01 |
fix
|
5 years ago |
9 changed files with 329 additions and 14 deletions
-
4README.md
-
41lib/data.js
-
61lib/http.js
-
2lib/main.js
-
40lib/tray.js
-
34lib/web/data.js
-
130lib/web/main.js
-
21main.js
-
10res/post-commit
@ -0,0 +1,61 @@ |
|||
|
|||
const { Notification } = require('electron') |
|||
|
|||
var http = require("http"); |
|||
var querystring = require("querystring"); |
|||
var url = require("url"); |
|||
const path = require('path') |
|||
const libdata = require(path.join(__dirname, 'data.js')); |
|||
exports.start = function () { |
|||
http.createServer(function (request, response) { |
|||
|
|||
var pathname = url.parse(request.url).pathname; |
|||
if (HttpMap[pathname]) { |
|||
HttpMap[pathname](request, response) |
|||
} else { |
|||
response.end("请求未定义"); |
|||
} |
|||
}).listen(37188); |
|||
} |
|||
|
|||
HttpMap = { |
|||
"/commit": function (request, response) { |
|||
let query = querystring.parse(url.parse(request.url).query); |
|||
let branch = query["branch"]; |
|||
let commit = query["commit"]; |
|||
if (!branch || !commit) { |
|||
console.log([branch, commit]); |
|||
response.end("error"); |
|||
return; |
|||
} |
|||
let branchSplit = branch.split("-"); |
|||
let commitSplit = commit.split(" "); |
|||
if (branchSplit.length < 2 || commitSplit.length < 2) { |
|||
console.log([branch, commit, "error"]); |
|||
response.end("error"); |
|||
return; |
|||
} |
|||
let id = branchSplit[0]; |
|||
let hash = commitSplit.shift(); |
|||
commit = commitSplit.join(" "); |
|||
if (commit[0] == '-' || commit[0] == '#') { |
|||
console.log([branch, commit, "skip commit"]); |
|||
(new Notification({ |
|||
title: "有一条新的提交被忽略", |
|||
body: `分支:${branch} 提交内容:${commit}` |
|||
})).show() |
|||
|
|||
response.end("skip commit"); |
|||
return; |
|||
} |
|||
libdata.AddCommitToQueue({ |
|||
id: id, |
|||
branch: branch, |
|||
hash: hash, |
|||
commit: commit, |
|||
}); |
|||
|
|||
console.log([branch, commit, "success"]); |
|||
response.end("success"); |
|||
} |
|||
} |
@ -0,0 +1,10 @@ |
|||
#!/bin/sh |
|||
|
|||
branch=`git symbolic-ref --short -q HEAD` |
|||
commit=`git log -1 --oneline $branch` |
|||
|
|||
branchencode=`echo -n "$branch" | xxd -ps | tr -d '\n' | sed -r 's/(..)/%\1/g'` |
|||
commitencode=`echo -n "$commit" | xxd -ps | tr -d '\n' | sed -r 's/(..)/%\1/g'` |
|||
curl "http://127.0.0.1:37188/commit?branch=${branchencode}&commit=${commitencode}" |
|||
echo 分支[$branch][$commit] |
|||
exit 0 |
Write
Preview
Loading…
Cancel
Save
Reference in new issue