Merge remote-tracking branch 'upstream/main' into ssh-mirroring

This commit is contained in:
techknowlogick committed 2025-08-08 12:13:01 -04:00
commit cee2ca0a7f
266 files changed
+5415 -7386

No files matched your search

+40 -30
View File
@@ -46,7 +46,7 @@ func (Action) ListActionsSecrets(ctx *context.APIContext) {
// parameters:
// - name: owner
// in: path
// description: owner of the repository
// description: owner of the repo
// type: string
// required: true
// - name: repo
@@ -216,7 +216,7 @@ func (Action) GetVariable(ctx *context.APIContext) {
// parameters:
// - name: owner
// in: path
// description: name of the owner
// description: owner of the repo
// type: string
// required: true
// - name: repo
@@ -270,7 +270,7 @@ func (Action) DeleteVariable(ctx *context.APIContext) {
// parameters:
// - name: owner
// in: path
// description: name of the owner
// description: owner of the repo
// type: string
// required: true
// - name: repo
@@ -319,7 +319,7 @@ func (Action) CreateVariable(ctx *context.APIContext) {
// parameters:
// - name: owner
// in: path
// description: name of the owner
// description: owner of the repo
// type: string
// required: true
// - name: repo
@@ -386,7 +386,7 @@ func (Action) UpdateVariable(ctx *context.APIContext) {
// parameters:
// - name: owner
// in: path
// description: name of the owner
// description: owner of the repo
// type: string
// required: true
// - name: repo
@@ -458,7 +458,7 @@ func (Action) ListVariables(ctx *context.APIContext) {
// parameters:
// - name: owner
// in: path
// description: name of the owner
// description: owner of the repo
// type: string
// required: true
// - name: repo
@@ -660,7 +660,7 @@ func (Action) ListWorkflowJobs(ctx *context.APIContext) {
// parameters:
// - name: owner
// in: path
// description: name of the owner
// description: owner of the repo
// type: string
// required: true
// - name: repo
@@ -704,7 +704,7 @@ func (Action) ListWorkflowRuns(ctx *context.APIContext) {
// parameters:
// - name: owner
// in: path
// description: name of the owner
// description: owner of the repo
// type: string
// required: true
// - name: repo
@@ -1110,7 +1110,7 @@ func GetWorkflowRun(ctx *context.APIContext) {
// parameters:
// - name: owner
// in: path
// description: name of the owner
// description: owner of the repo
// type: string
// required: true
// - name: repo
@@ -1132,18 +1132,23 @@ func GetWorkflowRun(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
runID := ctx.PathParamInt64("run")
job, _, err := db.GetByID[actions_model.ActionRun](ctx, runID)
if err != nil || job.RepoID != ctx.Repo.Repository.ID {
ctx.APIError(http.StatusNotFound, util.ErrNotExist)
}
convertedArtifact, err := convert.ToActionWorkflowRun(ctx, ctx.Repo.Repository, job)
job, has, err := db.GetByID[actions_model.ActionRun](ctx, runID)
if err != nil {
ctx.APIErrorInternal(err)
return
}
ctx.JSON(http.StatusOK, convertedArtifact)
if !has || job.RepoID != ctx.Repo.Repository.ID {
ctx.APIErrorNotFound(util.ErrNotExist)
return
}
convertedRun, err := convert.ToActionWorkflowRun(ctx, ctx.Repo.Repository, job)
if err != nil {
ctx.APIErrorInternal(err)
return
}
ctx.JSON(http.StatusOK, convertedRun)
}
// ListWorkflowRunJobs Lists all jobs for a workflow run.
@@ -1156,7 +1161,7 @@ func ListWorkflowRunJobs(ctx *context.APIContext) {
// parameters:
// - name: owner
// in: path
// description: name of the owner
// description: owner of the repo
// type: string
// required: true
// - name: repo
@@ -1215,7 +1220,7 @@ func GetWorkflowJob(ctx *context.APIContext) {
// parameters:
// - name: owner
// in: path
// description: name of the owner
// description: owner of the repo
// type: string
// required: true
// - name: repo
@@ -1237,10 +1242,15 @@ func GetWorkflowJob(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
jobID := ctx.PathParamInt64("job_id")
job, _, err := db.GetByID[actions_model.ActionRunJob](ctx, jobID)
job, has, err := db.GetByID[actions_model.ActionRunJob](ctx, jobID)
if err != nil {
ctx.APIErrorInternal(err)
return
}
if err != nil || job.RepoID != ctx.Repo.Repository.ID {
ctx.APIError(http.StatusNotFound, util.ErrNotExist)
if !has || job.RepoID != ctx.Repo.Repository.ID {
ctx.APIErrorNotFound(util.ErrNotExist)
return
}
convertedWorkflowJob, err := convert.ToActionWorkflowJob(ctx, ctx.Repo.Repository, nil, job)
@@ -1251,7 +1261,7 @@ func GetWorkflowJob(ctx *context.APIContext) {
ctx.JSON(http.StatusOK, convertedWorkflowJob)
}
// GetArtifacts Lists all artifacts for a repository.
// GetArtifactsOfRun Lists all artifacts for a repository.
func GetArtifactsOfRun(ctx *context.APIContext) {
// swagger:operation GET /repos/{owner}/{repo}/actions/runs/{run}/artifacts repository getArtifactsOfRun
// ---
@@ -1261,7 +1271,7 @@ func GetArtifactsOfRun(ctx *context.APIContext) {
// parameters:
// - name: owner
// in: path
// description: name of the owner
// description: owner of the repo
// type: string
// required: true
// - name: repo
@@ -1330,7 +1340,7 @@ func DeleteActionRun(ctx *context.APIContext) {
// parameters:
// - name: owner
// in: path
// description: name of the owner
// description: owner of the repo
// type: string
// required: true
// - name: repo
@@ -1354,7 +1364,7 @@ func DeleteActionRun(ctx *context.APIContext) {
runID := ctx.PathParamInt64("run")
run, err := actions_model.GetRunByRepoAndID(ctx, ctx.Repo.Repository.ID, runID)
if errors.Is(err, util.ErrNotExist) {
ctx.APIError(http.StatusNotFound, err)
ctx.APIErrorNotFound(err)
return
} else if err != nil {
ctx.APIErrorInternal(err)
@@ -1382,7 +1392,7 @@ func GetArtifacts(ctx *context.APIContext) {
// parameters:
// - name: owner
// in: path
// description: name of the owner
// description: owner of the repo
// type: string
// required: true
// - name: repo
@@ -1443,7 +1453,7 @@ func GetArtifact(ctx *context.APIContext) {
// parameters:
// - name: owner
// in: path
// description: name of the owner
// description: owner of the repo
// type: string
// required: true
// - name: repo
@@ -1492,7 +1502,7 @@ func DeleteArtifact(ctx *context.APIContext) {
// parameters:
// - name: owner
// in: path
// description: name of the owner
// description: owner of the repo
// type: string
// required: true
// - name: repo
@@ -1559,7 +1569,7 @@ func DownloadArtifact(ctx *context.APIContext) {
// parameters:
// - name: owner
// in: path
// description: name of the owner
// description: owner of the repo
// type: string
// required: true
// - name: repo
+1 -1
View File
@@ -21,7 +21,7 @@ func DownloadActionsRunJobLogs(ctx *context.APIContext) {
// parameters:
// - name: owner
// in: path
// description: name of the owner
// description: owner of the repo
// type: string
// required: true
// - name: repo
+2 -2
View File
@@ -210,7 +210,7 @@ func GetRawFileOrLFS(ctx *context.APIContext) {
if setting.LFS.Storage.ServeDirect() {
// If we have a signed url (S3, object storage), redirect to this directly.
u, err := storage.LFS.URL(pointer.RelativePath(), blob.Name(), nil)
u, err := storage.LFS.URL(pointer.RelativePath(), blob.Name(), ctx.Req.Method, nil)
if u != nil && err == nil {
ctx.Redirect(u.String())
return
@@ -331,7 +331,7 @@ func download(ctx *context.APIContext, archiveName string, archiver *repo_model.
rPath := archiver.RelativePath()
if setting.RepoArchive.Storage.ServeDirect() {
// If we have a signed url (S3, object storage), redirect to this directly.
u, err := storage.RepoArchives.URL(rPath, downloadName, nil)
u, err := storage.RepoArchives.URL(rPath, downloadName, ctx.Req.Method, nil)
if u != nil && err == nil {
ctx.Redirect(u.String())
return
+6 -6
View File
@@ -52,7 +52,7 @@ func ListPullRequests(ctx *context.APIContext) {
// parameters:
// - name: owner
// in: path
// description: Owner of the repo
// description: owner of the repo
// type: string
// required: true
// - name: repo
@@ -1461,9 +1461,9 @@ func GetPullRequestCommits(ctx *context.APIContext) {
defer closer.Close()
if pr.HasMerged {
prInfo, err = baseGitRepo.GetCompareInfo(pr.BaseRepo.RepoPath(), pr.MergeBase, pr.GetGitRefName(), false, false)
prInfo, err = baseGitRepo.GetCompareInfo(pr.BaseRepo.RepoPath(), pr.MergeBase, pr.GetGitHeadRefName(), false, false)
} else {
prInfo, err = baseGitRepo.GetCompareInfo(pr.BaseRepo.RepoPath(), pr.BaseBranch, pr.GetGitRefName(), false, false)
prInfo, err = baseGitRepo.GetCompareInfo(pr.BaseRepo.RepoPath(), pr.BaseBranch, pr.GetGitHeadRefName(), false, false)
}
if err != nil {
ctx.APIErrorInternal(err)
@@ -1584,16 +1584,16 @@ func GetPullRequestFiles(ctx *context.APIContext) {
var prInfo *git.CompareInfo
if pr.HasMerged {
prInfo, err = baseGitRepo.GetCompareInfo(pr.BaseRepo.RepoPath(), pr.MergeBase, pr.GetGitRefName(), true, false)
prInfo, err = baseGitRepo.GetCompareInfo(pr.BaseRepo.RepoPath(), pr.MergeBase, pr.GetGitHeadRefName(), true, false)
} else {
prInfo, err = baseGitRepo.GetCompareInfo(pr.BaseRepo.RepoPath(), pr.BaseBranch, pr.GetGitRefName(), true, false)
prInfo, err = baseGitRepo.GetCompareInfo(pr.BaseRepo.RepoPath(), pr.BaseBranch, pr.GetGitHeadRefName(), true, false)
}
if err != nil {
ctx.APIErrorInternal(err)
return
}
headCommitID, err := baseGitRepo.GetRefCommitID(pr.GetGitRefName())
headCommitID, err := baseGitRepo.GetRefCommitID(pr.GetGitHeadRefName())
if err != nil {
ctx.APIErrorInternal(err)
return
+2 -2
View File
@@ -336,7 +336,7 @@ func CreatePullReview(ctx *context.APIContext) {
}
defer closer.Close()
headCommitID, err := gitRepo.GetRefCommitID(pr.GetGitRefName())
headCommitID, err := gitRepo.GetRefCommitID(pr.GetGitHeadRefName())
if err != nil {
ctx.APIErrorInternal(err)
return
@@ -455,7 +455,7 @@ func SubmitPullReview(ctx *context.APIContext) {
return
}
headCommitID, err := ctx.Repo.GitRepo.GetRefCommitID(pr.GetGitRefName())
headCommitID, err := ctx.Repo.GitRepo.GetRefCommitID(pr.GetGitHeadRefName())
if err != nil {
ctx.APIErrorInternal(err)
return
+13 -33
View File
@@ -329,7 +329,7 @@ func Generate(ctx *context.APIContext) {
// parameters:
// - name: template_owner
// in: path
// description: name of the template repository owner
// description: owner of the template repository
// type: string
// required: true
// - name: template_repo
@@ -772,13 +772,8 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
var units []repo_model.RepoUnit
var deleteUnitTypes []unit_model.Type
currHasIssues := repo.UnitEnabled(ctx, unit_model.TypeIssues)
newHasIssues := currHasIssues
if opts.HasIssues != nil {
newHasIssues = *opts.HasIssues
}
if currHasIssues || newHasIssues {
if newHasIssues && opts.ExternalTracker != nil && !unit_model.TypeExternalTracker.UnitGlobalDisabled() {
if *opts.HasIssues && opts.ExternalTracker != nil && !unit_model.TypeExternalTracker.UnitGlobalDisabled() {
// Check that values are valid
if !validation.IsValidExternalURL(opts.ExternalTracker.ExternalTrackerURL) {
err := errors.New("External tracker URL not valid")
@@ -802,7 +797,7 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
},
})
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeIssues)
} else if newHasIssues && opts.ExternalTracker == nil && !unit_model.TypeIssues.UnitGlobalDisabled() {
} else if *opts.HasIssues && opts.ExternalTracker == nil && !unit_model.TypeIssues.UnitGlobalDisabled() {
// Default to built-in tracker
var config *repo_model.IssuesConfig
@@ -829,7 +824,7 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
Config: config,
})
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeExternalTracker)
} else if !newHasIssues {
} else if !*opts.HasIssues {
if !unit_model.TypeExternalTracker.UnitGlobalDisabled() {
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeExternalTracker)
}
@@ -839,13 +834,8 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
}
}
currHasWiki := repo.UnitEnabled(ctx, unit_model.TypeWiki)
newHasWiki := currHasWiki
if opts.HasWiki != nil {
newHasWiki = *opts.HasWiki
}
if currHasWiki || newHasWiki {
if newHasWiki && opts.ExternalWiki != nil && !unit_model.TypeExternalWiki.UnitGlobalDisabled() {
if *opts.HasWiki && opts.ExternalWiki != nil && !unit_model.TypeExternalWiki.UnitGlobalDisabled() {
// Check that values are valid
if !validation.IsValidExternalURL(opts.ExternalWiki.ExternalWikiURL) {
err := errors.New("External wiki URL not valid")
@@ -861,7 +851,7 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
},
})
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeWiki)
} else if newHasWiki && opts.ExternalWiki == nil && !unit_model.TypeWiki.UnitGlobalDisabled() {
} else if *opts.HasWiki && opts.ExternalWiki == nil && !unit_model.TypeWiki.UnitGlobalDisabled() {
config := &repo_model.UnitConfig{}
units = append(units, repo_model.RepoUnit{
RepoID: repo.ID,
@@ -869,7 +859,7 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
Config: config,
})
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeExternalWiki)
} else if !newHasWiki {
} else if !*opts.HasWiki {
if !unit_model.TypeExternalWiki.UnitGlobalDisabled() {
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeExternalWiki)
}
@@ -879,13 +869,8 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
}
}
currHasPullRequests := repo.UnitEnabled(ctx, unit_model.TypePullRequests)
newHasPullRequests := currHasPullRequests
if opts.HasPullRequests != nil {
newHasPullRequests = *opts.HasPullRequests
}
if currHasPullRequests || newHasPullRequests {
if newHasPullRequests && !unit_model.TypePullRequests.UnitGlobalDisabled() {
if opts.HasPullRequests != nil && !unit_model.TypePullRequests.UnitGlobalDisabled() {
if *opts.HasPullRequests {
// We do allow setting individual PR settings through the API, so
// we get the config settings and then set them
// if those settings were provided in the opts.
@@ -953,18 +938,13 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
Type: unit_model.TypePullRequests,
Config: config,
})
} else if !newHasPullRequests && !unit_model.TypePullRequests.UnitGlobalDisabled() {
} else {
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypePullRequests)
}
}
currHasProjects := repo.UnitEnabled(ctx, unit_model.TypeProjects)
newHasProjects := currHasProjects
if opts.HasProjects != nil {
newHasProjects = *opts.HasProjects
}
if currHasProjects || newHasProjects {
if newHasProjects && !unit_model.TypeProjects.UnitGlobalDisabled() {
if opts.HasProjects != nil && !unit_model.TypeProjects.UnitGlobalDisabled() {
if *opts.HasProjects {
unit, err := repo.GetUnit(ctx, unit_model.TypeProjects)
var config *repo_model.ProjectsConfig
if err != nil {
@@ -984,7 +964,7 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
Type: unit_model.TypeProjects,
Config: config,
})
} else if !newHasProjects && !unit_model.TypeProjects.UnitGlobalDisabled() {
} else {
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeProjects)
}
}