Commit graph

35 commits

Author SHA1 Message Date
Aditya Sirish
79efbf235f
gitinterface: Support types for tree entries
Signed-off-by: Aditya Sirish <aditya@saky.in>
2025-02-02 14:07:34 -05:00
Aditya Sirish
3236696c98
*: Extend TreeBuilder to reuse existing trees
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>
2025-02-02 12:06:18 -05:00
Pat Zielinski
6cf9823f2e gitinterface: Add TestRepositoryCommitUsingSpecificKey
Co-authored-by: Raghava Gatadi <raghava.gtd@gmail.com>
Signed-off-by: Pat Zielinski <70954403+patzielinski@users.noreply.github.com>
2025-01-15 16:00:10 -05:00
Aditya Sirish
95f2077c6b
Merge pull request #549 from Yasho-Bapat/test-coverage
increasing policy.go test coverage
2024-09-28 12:31:15 -04:00
Aditya Sirish
dd1d8b2f46
*: Fix newlines
Signed-off-by: Aditya Sirish <aditya@saky.in>
2024-09-28 12:28:41 -04:00
Pat Zielinski
d571facb8d *: Add copyright notice to code files
Signed-off-by: Pat Zielinski <70954403+patzielinski@users.noreply.github.com>
2024-09-27 15:28:12 -04:00
Aditya Sirish
929e0d162d
*: Automatically reconcile local RSL with remote updates
This commit adds ReconcileLocalRSLWithRemote, which checks the local RSL
against the specified remote and reconciles the local RSL if needed. If
the local RSL doesn't exist or is strictly behind the remote RSL, then
the local RSL is updated to match the remote RSL. If the local RSL is
ahead of the remote RSL, nothing is updated. Finally, if the local and
remote RSLs have diverged, then the local only RSL entries are reapplied
over the latest entries in the remote if the local only RSL entries and
remote only entries are for different Git references.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2024-09-25 14:02:59 -04:00
yashobapat
2d0d65ca08 reuse err fix (minor)
Signed-off-by: yashobapat <f20210006@goa.bits-pilani.ac.in>
2024-09-24 15:05:16 -04:00
yashobapat
318b293816 verify commit sig
Signed-off-by: yashobapat <f20210006@goa.bits-pilani.ac.in>
2024-09-24 15:01:22 -04:00
yashobapat
21ff68c9a3 fix linting
Signed-off-by: yashobapat <f20210006@goa.bits-pilani.ac.in>
2024-09-24 14:32:17 -04:00
Yasho-Bapat
b3aba609d9 increase policy/policy.go and gitinterface/commit.go test coverage, fix linting
Signed-off-by: yashobapat <f20210006@goa.bits-pilani.ac.in>
2024-09-24 14:32:01 -04:00
Aditya Sirish A Yelgundhalli
fe6d1d343a
*: Drop old gitinterface APIs
This commit also renames ReplacementTreeBuilder to TreeBuilder.

Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-07-01 10:21:25 -04:00
Aditya Sirish A Yelgundhalli
b0c6bac73b gitinterface: Fixes for tests
Signed-off-by: Aditya Sirish A Yelgundhalli <ayelgundhall@bloomberg.net>
2024-06-11 16:46:22 -04:00
Aditya Sirish
a0e62aa8b7
gitinterface: RSA keys in tests for Windows compat
Signed-off-by: Aditya Sirish <aditya@saky.in>
2024-05-28 15:47:54 +05:30
Aditya Sirish
aae8e0cbdf
gitinterface: Add commits and tags
Signed-off-by: Aditya Sirish <aditya@saky.in>
2024-05-22 23:39:19 +05:30
Aditya Sirish
03159de27f
*: Centralize test artifacts
Signed-off-by: Aditya Sirish <aditya@saky.in>
2024-01-15 00:23:47 -05:00
Aditya Sirish
3397ac9bad
*: Vendor go-sslib with new signerverifier flows
Signed-off-by: Aditya Sirish <aditya@saky.in>
2024-01-15 00:22:53 -05:00
Aditya Sirish
1ab613b589
gitinterface: Update SSH signature verification
Signed-off-by: Aditya Sirish <aditya@saky.in>
2024-01-09 13:49:11 -05:00
Aditya Sirish
588a31e025
gitinterface: Support verifying SSH key signatures
Also updates error chaining in signature verification to preserve error
context, making debugging easier.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2024-01-09 11:20:27 -05:00
Aditya Sirish
2fd0988424
dep: Remove vendored copy of go-git
Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-11-29 21:04:54 +05:30
neilnaveen
40ed92a52d Make CreateCommitObject Support Merge Commits
- Make CreateCommitObject support merge commits, with multiple parent
  hashes
- Changed other files to use an array of parent hashes instead of a
  single hash
- By changing the parameters for CreateCommitObject, internal/common had
  errors that had to be fixed.

Signed-off-by: neilnaveen <42328488+neilnaveen@users.noreply.github.com>
2023-11-06 15:55:59 -06:00
Aditya Sirish
0541411fc1
*: Route GetObject requests through gitinterface
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>
2023-10-26 11:13:32 -04:00
Billy Lynch
d57191618a
Remove module replace in favor of a package fork.
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>
2023-10-25 19:25:56 -04:00
Pat Zielinski
d0905e7816 Add SPDX License Identifiers to code files
Signed-off-by: Pat Zielinski <70954403+patzielinski@users.noreply.github.com>
2023-10-09 08:09:34 -04:00
Aditya Sirish
106f034933
Merge pull request #113 from gittuf/tags
Add support for tags
2023-09-15 14:34:23 -04:00
Aditya Sirish
ad96717b0e
gitinterface: Fix test config value and invocation
This fixes a previously unnoticed bug in setting the test config where
the user's name and email were actually left blank. This is an issue
with how go-git parses the raw parts of the config vs the defined
structs. This was primarily noticed because of mismatched hashes on
GitHub actions in the tag, the expected values have changed in some
existing tests as well.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-09-13 13:30:16 -04:00
Aditya Sirish
f7eb00a6d6
*: Clean up GPG key load from bytes
Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-09-13 11:26:19 -04:00
Aditya Sirish
29b795abe3
*: Update gitinterface.Commit behavior
1. Commit now returns the ID of the newly created commit. This will help
   us avoid extraneous calls to repo.Reference to get the new state of
   the affected ref.
2. Commit also creates the ref if it doesn't already exist. This allows
   to skip initializing (to zero) refs we're about to commit to anyway.
   Note: this commit does not actually remove those extra
   initializations. That is left to a future patch or clean up pass.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-09-12 13:06:53 -04:00
Aditya Sirish
b850488960
gitinterface: Changes and commit reachability
* Add functions to track changes introduced by commits or between commits
* Add function to check if a commit knows another using reachability

Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-09-11 15:34:14 -04:00
Aditya Sirish
3192cdb861
Rename module to use gittuf org
Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-08-30 13:13:54 -04:00
Aditya Sirish
d48a0b8ead
common, gitinterface: Clean up test data
Define test data such as user information, Git config, fake clock once
at most per package.

Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-08-18 16:32:21 -04:00
Aditya Sirish
5bb804a767
gitinterface: Identify changed files
Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-08-18 16:07:45 -04:00
Aditya Sirish
0d4be41b91
Early gitsign support
This commit introduces early, experimental support for gitsign
signatures on git commits. It uses TAP-18 to specify sigstore identity
constraints in delegations.

The feature introduced here depends on unreleased prototype code in
go-securesystemslib and is also insufficiently tested due to some
sigstore library constraints.

See: #73

Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-08-07 15:27:37 -04:00
Aditya Sirish
24244629a7
gitinterface, sv: Add support for GPG signing
Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-06-20 15:48:00 -07:00
Aditya Sirish
c94f87d5f9
Add gitinterface package
This package includes a set of helpers to interface with the underlying
git repository. Features:
* parse git configs to determine commit signing mechanism
* create and sign commit objects

Signed-off-by: Aditya Sirish <aditya@saky.in>
2023-02-20 14:09:44 -05:00