-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommit_fetcher.py
52 lines (42 loc) · 1.73 KB
/
commit_fetcher.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
40
41
42
43
44
45
46
47
48
49
50
51
52
import config
from datetime import date, timedelta
class CommitFetcher:
def __init__(self,repo):
self.required_commits_=[]
self.config=config.get_config_file()
self.repo=repo
def get_commits(self):
return self.required_commits_
def get_committers(self):
c=self.repo.iter_commits()
committers=[]
index=1
for x in c:
if(not x.author.name in committers):
committers.append(x.author.name)
index=index+1
if(index>15):
break
return committers
class LastCommitFetcher(CommitFetcher):
def get_commits(self):
""" Gets the commits of the user that needs to be logged """
commits = self.repo.iter_commits()
user = self.config['source_repo']['committer']
for commit in commits:
# Get user's commit and make sure it is not a MERGE commit
if(commit.author.name == user and len(commit.parents) == 1):
self.required_commits_.append(commit)
break
return self.required_commits_
class CurrentDayCommitFetcher(CommitFetcher):
def get_commits(self):
commits = self.repo.iter_commits()
user = self.config['source_repo']['committer']
for commit in commits:
# Get user's commit and make sure it is not a MERGE commit
if(commit.author.name == user and len(commit.parents) == 1 and commit.committed_datetime.date()==date.today()):
print(commit)
self.required_commits_.append(commit)
break
return self.required_commits_