gittuf / gittuf

A security layer for Git repositories
https://gittuf.dev
Apache License 2.0
439 stars 28 forks source link

gitinterface: Fix test failing on Windows #408

Closed patzielinski closed 1 month ago

patzielinski commented 1 month ago

This PR fixes CI on Windows failing due to a test in gitinterface by manually working with the temporary directory.

Addresses #407.

patzielinski commented 1 month ago

I need to tinker a bit more with this, marking as draft.

patzielinski commented 1 month ago

Turns out that all that was needed was a deferred call to an os.Chdir to the global temp dir as open folders cannot be deleted on Windows, unlike *nix based systems.

@adityasaky Do we still want to move the tempfile creation into CreateTestGitRepository? We do provide the directory so we still know where the repo will be...

adityasaky commented 1 month ago

https://github.com/gittuf/gittuf/blob/main/internal/gitinterface/common.go#L47-L49

is it because we never reverse this then? Because we can replace that chdir with git init -b main <dir> no?

patzielinski commented 1 month ago

https://github.com/gittuf/gittuf/blob/main/internal/gitinterface/common.go#L47-L49

is it because we never reverse this then? Because we can replace that chdir with git init -b main <dir> no?

Yep, that's exactly why.