This commit is contained in:
9 files changed
+633
-114
No files matched your search
@@ -430,3 +430,25 @@ func (f *Forge) GetRepoArchive(ctx context.Context, owner, repo, ref string) (io
|
||||
}()
|
||||
return pr, nil
|
||||
}
|
||||
|
||||
// GitCredential asks the extension for a per-repository git credential. An
|
||||
// extension without one answers errors.ErrUnsupported.
|
||||
func (f *Forge) GitCredential(ctx context.Context, owner, repo string) (forge.GitCredential, error) {
|
||||
resp, err := call(ctx, f, "git credential", func(c forgev1.ForgeServiceClient) (*forgev1.GitCredentialResponse, error) {
|
||||
resp, err := c.GitCredential(ctx, &forgev1.GitCredentialRequest{Repo: ref(owner, repo)})
|
||||
if status.Code(err) == codes.Unimplemented {
|
||||
return nil, nil
|
||||
}
|
||||
return resp, err
|
||||
})
|
||||
if err != nil {
|
||||
return forge.GitCredential{}, err
|
||||
}
|
||||
if resp == nil {
|
||||
return forge.GitCredential{}, errors.ErrUnsupported
|
||||
}
|
||||
return forge.GitCredential{
|
||||
Username: resp.GetUsername(), Token: resp.GetToken(), ExpiresAt: resp.GetExpiresAt().AsTime(),
|
||||
CommitName: resp.GetCommitName(), CommitEmail: resp.GetCommitEmail(),
|
||||
}, nil
|
||||
}
|
||||
Reference in new issue
Block a user