in probe_scraper/transform_probes.py [0:0]
def make_item_defn(definition, commit: Commit, new_source_url: Optional[str] = None):
if COMMITS_KEY not in definition:
# This is the first time we've seen this definition
definition[COMMITS_KEY] = {"first": commit.hash, "last": commit.hash}
definition[DATES_KEY] = {
"first": commit.pretty_timestamp,
"last": commit.pretty_timestamp,
}
definition[REFLOG_KEY] = {
"first": commit.reflog_index,
"last": commit.reflog_index,
}
else:
# we've seen this definition, update the `last` commit and source url
last_dt = datetime.fromisoformat(definition[DATES_KEY]["last"])
last_timestamp = last_dt.replace(tzinfo=timezone.utc).timestamp()
last_reflog = definition[REFLOG_KEY]["last"]
# use negative last_reflog to match commit.sort_key()
if commit.is_head or (last_timestamp, -last_reflog) < commit.sort_key():
definition[COMMITS_KEY]["last"] = commit.hash
definition[DATES_KEY]["last"] = commit.pretty_timestamp
definition[REFLOG_KEY]["last"] = commit.reflog_index
# only update source url when the last commit changed
if new_source_url:
definition[SOURCE_URL_KEY] = new_source_url
return definition