Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gracefully handle commits where files are missing from git #357

Open
relud opened this issue Oct 27, 2021 · 0 comments
Open

Gracefully handle commits where files are missing from git #357

relud opened this issue Oct 27, 2021 · 0 comments

Comments

@relud
Copy link
Contributor

relud commented Oct 27, 2021

this code fails when there are commits where a file was deleted:

contents = get_file_at_hash(repo, _hash, rel_path)
def get_file_at_hash(repo, _hash, filename):
return repo.git.show("{hash}:{path}".format(hash=_hash, path=filename))

the current workaround requires listing every commit where the file was deleted:

# Some commits in projects might contain invalid metric files.
# When we know these problems are fixed in later commits we can skip them.
SKIP_COMMITS = {
"engine-gecko": [
"9bd9d7fa6c679f35d8cbeb157ff839c63b21a2e6" # Missing schema update from v1 to v2
],
"engine-gecko-beta": [
"9bd9d7fa6c679f35d8cbeb157ff839c63b21a2e6" # Missing schema update from v1 to v2
],
"gecko": [
"43d8cf138695faae2fca0adf44c94f47fdadfca8", # Missing gfx/metrics.yaml
"340c8521a54ad4d4a32dd16333676a6ff85aaec2", # Missing toolkit/components/glean/pings.yaml
"4520632fe0664572c5f70688595b7721d167e2d0", # Missing toolkit/components/glean/pings.yaml
],
}
skip_commits = SKIP_COMMITS.get(repo_info.name, [])
if _hash in skip_commits:
continue

That workaround is still needed for invalid files, but for missing files we should add code to handle the exception from git, probably with continue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant