package git

import "context"

// Push 推送 dir 当前 branch 到 origin/<branch>。
func (r *DefaultRunner) Push(ctx context.Context, dir, branch string, cred *Credential) error {
	ctx, cancel := withCtx(ctx, r.cfg.PushTimeout)
	defer cancel()
	env, cleanup, err := credentialEnv(r.cfg.TmpDir, cred)
	if err != nil {
		return err
	}
	defer cleanup()
	_, _, err = r.exec(ctx, dir, env, "push", "-u", "origin", branch)
	return err
}
