forked from gil9red/SimplePyScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.py
More file actions
54 lines (34 loc) · 1011 Bytes
/
Copy pathcommon.py
File metadata and controls
54 lines (34 loc) · 1011 Bytes
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = 'ipetrash'
LOGIN = None
PASSWORD = None
# http://user:password@proxy_host:proxy_port
PROXY = None
if PROXY:
import os
os.environ['http_proxy'] = PROXY
NEW_REPO = 'Test-Repo'
import os
REPO_PATH = os.path.abspath(NEW_REPO)
# How use without input login and password:
# git clone https://username:password@github.com/username/repository.git
URL_GIT = 'https://{0}:{1}@github.com/{0}/{2}.git'.format(LOGIN, PASSWORD, NEW_REPO)
def get_repo():
# pip install GitPython
import git
try:
return git.Repo(REPO_PATH)
except:
return git.Repo.clone_from(URL_GIT, REPO_PATH)
def return_log(reverse=False):
repo = get_repo()
logs = repo.git.log('--pretty=format:%H%x09%an%x09%ad%x09%s').splitlines()
if reverse:
logs.reverse()
return logs
def print_log(reverse=False):
logs = return_log(reverse)
print('Logs[{}]:'.format(len(logs)))
for log in logs:
print(log)