diff options
author | Edip Emre Bodur <emrebdr29@gmail.com> | 2024-08-13 05:53:43 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-13 02:53:43 +0000 |
commit | a4dac596434df0af7de28d9c1f4630ba32b10515 (patch) | |
tree | 9dd29171f115aac8f4dc5bf3fe2a83fdf1e70cf1 /services/repository/transfer.go | |
parent | 5bcab0b702274e137ff3e40f3ffa9078605fc2a2 (diff) | |
download | gitea-a4dac596434df0af7de28d9c1f4630ba32b10515.tar.gz gitea-a4dac596434df0af7de28d9c1f4630ba32b10515.zip |
Fixes for unreachable project issues when transfer repository from organization (#31770)
When transferring repositories that have issues linked to a project
board to another organization, the issues remain associated with the
original project board. This causes the columns in the project board to
become bugged, making it difficult to move other issues in or out of the
affected columns. As a solution, I removed the issue relations since the
other organization does not have this project table.
Fix for #31538
Co-authored-by: Jason Song <i@wolfogre.com>
Diffstat (limited to 'services/repository/transfer.go')
-rw-r--r-- | services/repository/transfer.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/services/repository/transfer.go b/services/repository/transfer.go index 9e0ff7ae14..f48653072a 100644 --- a/services/repository/transfer.go +++ b/services/repository/transfer.go @@ -15,6 +15,7 @@ import ( "code.gitea.io/gitea/models/organization" "code.gitea.io/gitea/models/perm" access_model "code.gitea.io/gitea/models/perm/access" + project_model "code.gitea.io/gitea/models/project" repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/log" @@ -177,6 +178,22 @@ func transferOwnership(ctx context.Context, doer *user_model.User, newOwnerName } } + // Remove project's issues that belong to old organization's projects + if oldOwner.IsOrganization() { + projects, err := project_model.GetAllProjectsIDsByOwnerIDAndType(ctx, oldOwner.ID, project_model.TypeOrganization) + if err != nil { + return fmt.Errorf("Unable to find old org projects: %w", err) + } + issues, err := issues_model.GetIssueIDsByRepoID(ctx, repo.ID) + if err != nil { + return fmt.Errorf("Unable to find repo's issues: %w", err) + } + err = project_model.DeleteAllProjectIssueByIssueIDsAndProjectIDs(ctx, issues, projects) + if err != nil { + return fmt.Errorf("Unable to delete project's issues: %w", err) + } + } + if newOwner.IsOrganization() { teams, err := organization.FindOrgTeams(ctx, newOwner.ID) if err != nil { |