Skip to content

For some repos the file is not correctly read from each commit version #64

@simonw

Description

@simonw

https://pinafore.social/statuses/109671158910886602 reports problems loading the history for data/stats.json in https://github.com/Ambrosiani/GLAM_stats

Sure enough, I tried this:

cd /tmp
git clone https://github.com/Ambrosiani/GLAM_stats
cd GLAM_stats
git-history file stats.db data/stats.json --id name --branch master

Output:

  [####################################]  176/176  100%%                        GLAM_stats % 

But:

% sqlite-utils dump stats.db
BEGIN TRANSACTION;
CREATE TABLE [namespaces] (
   [id] INTEGER PRIMARY KEY,
   [name] TEXT
);
INSERT INTO "namespaces" VALUES(1,'item');
CREATE UNIQUE INDEX [idx_namespaces_name]
    ON [namespaces] ([name]);
COMMIT;

So it didn't actually work.

On a bit of debugging it turns out this code was at fault:

for commit in commits:
if progress_bar:
progress_bar.update(1)
try:
blob = [b for b in commit.tree.blobs if b.name == relative_path][0]
yield commit.committed_datetime, commit.hexsha, blob.data_stream.read()
except IndexError:
# This commit doesn't have a copy of the requested file
pass

The "This commit doesn't have a copy of the requested file" branch was being hit for every commit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions