Commit Graph

5 Commits

Author SHA1 Message Date
Sunny 5bd08a6960 Add Host field check in AuthOptions.Validate()
For ssh, Host field is required in AuthOptions.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-10-27 00:43:31 +05:30
Hidde Beydals 99428f593e libgit2: change credentialsCallback logic
This changes the logic of `credentialsCallback` so that it takes the
`allowedTypes` passed on by `git2go` into account. Reason for this
change is because this prepares it to work with `v33`, but also
because it can provide better guidance when `libgit2` has been
compiled with a different configuration, which e.g. doesn't
allow for "in-memory SSH keys".

Because `AuthOptions#Identity` now gets validated by the callback
and go-git does its own validaiton, the check has been removed
from `Validate` (and now does a simple check if the fields are set).

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-10-27 00:43:31 +05:30
Sunny 942c310195 pkg/git: AuthOptions.Validate() test improvements
Adds more test cases for Validate() and an error for unknown transport.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-10-27 00:43:31 +05:30
Hidde Beydals b7376ce94c gogit: allow checkout of commit without branch
This commit changes the `gogit` behavior for commit checkouts,
now allowing one to reference to just a commit while omitting any
branch reference. Doing this creates an Artifact with a
`HEAD/<commit>` revision.

If both a `branch` and `commit` are defined, the commit is expected
to exist within the branch. This results in a more efficient clone
of just the target branch, and also makes this change backwards
compatible.

Fixes #407
Fixes #315

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-10-27 00:43:31 +05:30
Hidde Beydals 0cf0d4e756 git: refactor AuthStrategy into AuthOptions
This commit moves the previous `AuthStrategy` wiring to a more generic
`AuthOptions`, breaking free from implementation specific details in
the `git` package.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-10-27 00:43:31 +05:30