mirror of
https://github.com/Xevion/recommit.git
synced 2025-12-05 23:15:59 -06:00
Improve uniqueness checks to compensate for iteration-based commit ids
This commit is contained in:
17
sources.py
17
sources.py
@@ -67,13 +67,21 @@ class Gitlab(CommitSource):
|
||||
|
||||
# Check all events in the list
|
||||
for event in self.events(page=page, per_page=50):
|
||||
if event['action_name'].startswith('pushed') and not check_seen_function(event['id']):
|
||||
# Make sure this contribution event contains commits
|
||||
if not event['action_name'].startswith('pushed'):
|
||||
continue
|
||||
|
||||
# Check that we haven't seen this commit before.
|
||||
check_id: str = event['id'] if event['push_data']['commit_count'] == 1 else f"{event['id']}-00"
|
||||
if check_seen_function(check_id):
|
||||
continue
|
||||
|
||||
continue_fetching = True
|
||||
count: int = event['push_data']['commit_count']
|
||||
|
||||
if count == 1:
|
||||
results.append(Commit(
|
||||
id=event['id'],
|
||||
id=str(event['id']),
|
||||
project_id=event['project_id'],
|
||||
iteration=0,
|
||||
source=self.source_type,
|
||||
@@ -85,7 +93,7 @@ class Gitlab(CommitSource):
|
||||
results.append(Commit(
|
||||
id=f"{event['id']}-{i:02}",
|
||||
project_id=event['project_id'],
|
||||
iteration=0,
|
||||
iteration=i,
|
||||
source=self.source_type,
|
||||
timestamp=parser.isoparse(event['created_at']),
|
||||
seen_timestamp=datetime.datetime.utcnow()
|
||||
@@ -107,6 +115,9 @@ class Gitlab(CommitSource):
|
||||
params = {k: v for k, v in params.items() if v is not None}
|
||||
request = requests.Request('GET', self.url, params=params, headers=self.headers)
|
||||
prepped = self.session.prepare_request(request)
|
||||
|
||||
self.logger.info(f'{prepped.method} {prepped.url}')
|
||||
|
||||
response = self.session.send(prepped)
|
||||
|
||||
return response.json()
|
||||
|
||||
Reference in New Issue
Block a user