# 查询代码统计,各个分支下
git log --all --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --branches --all --since='2018-04-19 00:00:00' --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added line: %s, remove line: %s, total line: %s\n", add, subs, loc }' -; done
带用户名和密码git clone项目
git clone http://username:password@git.xin.cn/lanxinRdAll/lx_docs.git
模拟登陆
from bs4 import BeautifulSoup def parser_get_authenticity_token(html_cont): soup = BeautifulSoup(html_cont, 'lxml', from_encoding='utf-8') keys = soup.find_all('input', attrs={"name": "_csrf"}) print(keys[0]['value']) return keys[0]['value'] def requests_get_session(): session = requests.Session() response = session.get('http://git.xin.cn/user/login') count = response.text return session, count def post_longin(session, authenticity_token, user_name, password): data = { '_csrf': authenticity_token, 'user_name': user_name, 'password': password } header = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36'} response = session.post('http://git.xin.cn/user/login', data=data,headers=header) print(response.status_code) # print(session.cookies) return session def get_comisys_main(user_name, password): session, count = requests_get_session() authenticity_token = parser_get_authenticity_token(count) session = post_longin(session, authenticity_token, user_name, password) return session