-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommit.py
39 lines (32 loc) · 1.05 KB
/
commit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#-*- coding: utf-8 -*-
# Copyright 2019 ibelie, Chen Jie, Joungtao. All rights reserved.
# Use of this source code is governed by The MIT License
# that can be found in the LICENSE file.
import time
import os
import re
from properform import properform
def commit(url, token, profile, memleak):
originRe = re.compile(r'https://github.com/(?P<user>[^/]+)/(?P<project>[^\.]+).git', re.I)
with os.popen('git config --get remote.origin.url') as proc:
line = proc.readline()
while line:
m = originRe.match(line)
if m:
user = m.group('user')
project = m.group('project')
line = proc.readline()
with os.popen('git branch') as proc:
line = proc.readline().strip()
while line:
if line.startswith('* '):
branch = line[2:]
line = proc.readline().strip()
with os.popen('git rev-parse HEAD') as proc:
line = proc.readline().strip()
while line:
commit, line = line, proc.readline().strip()
properform.Push(url + '/properform', token, project, commit, profile, memleak, branch)
if __name__ == '__main__':
import sys
commit(*sys.argv[1:])