[GITRPC] Disable Credential Helper For Puhs (#511)

This commit is contained in:
Johannes Batzill 2023-09-15 21:24:07 +00:00 committed by Harness
parent 682efb9dba
commit e88a518da4
2 changed files with 6 additions and 2 deletions

View File

@ -193,7 +193,10 @@ func (g Adapter) Push(ctx context.Context, repoPath string, opts types.PushOptio
// NOTE: Modification of gitea implementation that supports --force-with-lease.
// TODOD: return our own error types and move to above adapter.Push method
func Push(ctx context.Context, repoPath string, opts types.PushOptions) error {
cmd := gitea.NewCommand(ctx, "push")
cmd := gitea.NewCommand(ctx,
"-c", "credential.helper=",
"push",
)
if opts.Force {
cmd.AddArguments("-f")
}

View File

@ -14,6 +14,7 @@ import (
"strings"
"time"
"github.com/harness/gitness/gitrpc/internal/gitea"
"github.com/harness/gitness/gitrpc/internal/middleware"
"github.com/harness/gitness/gitrpc/internal/tempdir"
"github.com/harness/gitness/gitrpc/internal/types"
@ -327,7 +328,7 @@ func (r *SharedRepo) push(ctx context.Context, writeRequest *rpc.WriteRequest,
sourceRef, destinationRef string) error {
// Because calls hooks we need to pass in the environment
env := CreateEnvironmentForPush(ctx, writeRequest)
if err := git.Push(ctx, r.tmpPath, git.PushOptions{
if err := gitea.Push(ctx, r.tmpPath, types.PushOptions{
Remote: r.remoteRepo.Path,
Branch: sourceRef + ":" + destinationRef,
Env: env,