0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-01-24 23:51:04 +01:00
This commit is contained in:
Excellencedev 2025-12-30 05:47:22 +01:00
parent de0d8da7b6
commit 4a9a54e2df
3 changed files with 13 additions and 0 deletions

View File

@ -356,6 +356,12 @@ func ReqChangeRepoFileOptionsAndCheck(ctx *context.APIContext) {
OldBranch: commonOpts.BranchName,
NewBranch: commonOpts.NewBranchName,
ForcePush: commonOpts.ForcePush,
ActionsTaskID: func() int64 {
if ctx.Data["ActionsTaskID"] != nil {
return ctx.Data["ActionsTaskID"].(int64)
}
return 0
}(),
Committer: &files_service.IdentityOptions{
GitUserName: commonOpts.Committer.Name,
GitUserEmail: commonOpts.Committer.Email,

View File

@ -33,6 +33,8 @@ type TemporaryUploadRepository struct {
gitRepo *git.Repository
basePath string
cleanup func()
ActionsTaskID int64
}
// NewTemporaryUploadRepository creates a new temporary upload repository
@ -362,6 +364,9 @@ func (t *TemporaryUploadRepository) CommitTree(ctx context.Context, opts *Commit
func (t *TemporaryUploadRepository) Push(ctx context.Context, doer *user_model.User, commitHash, branch string, force bool) error {
// Because calls hooks we need to pass in the environment
env := repo_module.PushingEnvironment(doer, t.repo)
if t.ActionsTaskID > 0 {
env = append(env, repo_module.EnvActionsTaskID+"="+fmt.Sprintf("%d", t.ActionsTaskID))
}
if err := gitrepo.PushFromLocal(ctx, t.basePath, t.repo, git.PushOptions{
Branch: strings.TrimSpace(commitHash) + ":" + git.BranchPrefix + strings.TrimSpace(branch),
Env: env,

View File

@ -64,6 +64,7 @@ type ChangeRepoFilesOptions struct {
Dates *CommitDateOptions
Signoff bool
ForcePush bool
ActionsTaskID int64
}
type RepoFileOptions struct {
@ -177,6 +178,7 @@ func ChangeRepoFiles(ctx context.Context, repo *repo_model.Repository, doer *use
if err != nil {
log.Error("NewTemporaryUploadRepository failed: %v", err)
}
t.ActionsTaskID = opts.ActionsTaskID
defer t.Close()
hasOldBranch := true
if err := t.Clone(ctx, opts.OldBranch, true); err != nil {