If an intermediate tree already exists and we know this ahead of time,
we should use it without recreating it with all of its contents resolved
and written recursively. This commit adds support for such cases and
renames TreeBuilder's APIs to generalize away from accepting blob IDs
only.
Signed-off-by: Aditya Sirish <aditya@saky.in>
Also addresses some required changes to tests hitting GetMergeTree via older
Git versions. This is because we use checkout to compute merge tree in those
cases, and we need to ensure that in the test, the worktree modified is that of
the temporary repository rather than the gittuf repository itself.
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
Co-authored-by: Pat Zielinski <70954403+patzielinski@users.noreply.github.com>
TreeBuilder allows for adding multiple files (with their blob IDs) to a
tree, creating intermediate trees on the fly based on the files' paths.
This is based significantly off "buildTreeHelper" in go-git. It's
possible this will eventually be upstreamed to go-git in plumbing and
used in "buildTreeHelper".
cc @pjbgf
Signed-off-by: Aditya Sirish <aditya@saky.in>
This allows us to perform additional checks in future such as whether an
object is replaced by a replace ref. It also makes it easier to switch
between go-git and another mechanism to invoke Git, such as directly
using the binary.
Signed-off-by: Aditya Sirish <aditya@saky.in>
This removes the sub-go.mod in favor of updating all references to the
third_party/go-git package.
This lets users `go install` from outside of the module.
Signed-off-by: Billy Lynch <billy@chainguard.dev>
Currently, we're using a zerohash for the tree ID for RSL entries. This
is flagged as an error by Git, and visible when trying to push to some
forges.
Signed-off-by: Aditya Sirish <aditya@saky.in>
This commit includes several plumbing changes.
* Support for trees and blobs in gitinterface
* Initialization of refs/gittuf independent of policy / RSL packages
* Initialization of policy and policy-staging namespaces
* rsl.InitializeNamespace is now only responsible for its own namespace
* Replaces some t.Error calls with t.Fatal
Signed-off-by: Aditya Sirish <aditya@saky.in>