feat: auto-create .profile repo with README and redirect to edit
Some checks failed
Build and Release / Create Release (push) Has been skipped
Build and Release / Lint (push) Failing after 3s
Build and Release / Build Binaries (amd64, darwin) (push) Has been skipped
Build and Release / Build Binaries (amd64, linux) (push) Has been skipped
Build and Release / Build Binaries (amd64, windows) (push) Has been skipped
Build and Release / Build Binaries (arm64, darwin) (push) Has been skipped
Build and Release / Build Binaries (arm64, linux) (push) Has been skipped
Build and Release / Integration Tests (PostgreSQL) (push) Successful in 48s
Build and Release / Unit Tests (push) Successful in 2m4s
Some checks failed
Build and Release / Create Release (push) Has been skipped
Build and Release / Lint (push) Failing after 3s
Build and Release / Build Binaries (amd64, darwin) (push) Has been skipped
Build and Release / Build Binaries (amd64, linux) (push) Has been skipped
Build and Release / Build Binaries (amd64, windows) (push) Has been skipped
Build and Release / Build Binaries (arm64, darwin) (push) Has been skipped
Build and Release / Build Binaries (arm64, linux) (push) Has been skipped
Build and Release / Integration Tests (PostgreSQL) (push) Successful in 48s
Build and Release / Unit Tests (push) Successful in 2m4s
This commit is contained in:
parent
5832d93f0a
commit
1af82412c0
@ -3817,5 +3817,7 @@
|
||||
"settings.show_heatmap_on_profile_popup": "Display your contribution heatmap on your profile overview page",
|
||||
"user.activity_heatmap": "Activity Heatmap",
|
||||
"org.stats": "Stats",
|
||||
"org.recent_activity": "Recent Activity"
|
||||
"org.recent_activity": "Recent Activity",
|
||||
"org.profile_repo_no_permission": "You do not have permission to create repositories in this organization.",
|
||||
"org.profile_repo_create_failed": "Failed to create the profile repository."
|
||||
}
|
||||
@ -22,6 +22,7 @@ import (
|
||||
shared_user "code.gitea.io/gitea/routers/web/shared/user"
|
||||
"code.gitea.io/gitea/services/context"
|
||||
org_service "code.gitea.io/gitea/services/org"
|
||||
repo_service "code.gitea.io/gitea/services/repository"
|
||||
)
|
||||
// RecentRepoActivity holds repo and its latest commit info
|
||||
type RecentRepoActivity struct {
|
||||
@ -286,3 +287,45 @@ func prepareOrgProfileReadme(ctx *context.Context, prepareResult *shared_user.Pr
|
||||
ctx.Data["IsViewingOrgAsMember"] = viewAsMember
|
||||
return true
|
||||
}
|
||||
|
||||
// CreateProfileRepo creates a .profile repository with README for the organization
|
||||
func CreateProfileRepo(ctx *context.Context) {
|
||||
org := ctx.Org.Organization
|
||||
|
||||
// Check if user can create repos in this org
|
||||
if !ctx.Org.CanCreateOrgRepo {
|
||||
ctx.Flash.Error(ctx.Tr("org.profile_repo_no_permission"))
|
||||
ctx.Redirect(org.AsUser().HomeLink())
|
||||
return
|
||||
}
|
||||
|
||||
// Check if .profile repo already exists
|
||||
exists, err := repo_model.IsRepositoryModelExist(ctx, org.AsUser(), ".profile")
|
||||
if err != nil {
|
||||
ctx.ServerError("IsRepositoryExist", err)
|
||||
return
|
||||
}
|
||||
if exists {
|
||||
ctx.Redirect(org.AsUser().HomeLink() + "/.profile")
|
||||
return
|
||||
}
|
||||
|
||||
// Create the .profile repository
|
||||
repo, err := repo_service.CreateRepository(ctx, ctx.Doer, org.AsUser(), repo_service.CreateRepoOptions{
|
||||
Name: ".profile",
|
||||
Description: "Organization profile",
|
||||
AutoInit: true,
|
||||
Readme: "Default",
|
||||
DefaultBranch: "main",
|
||||
IsPrivate: false,
|
||||
})
|
||||
if err != nil {
|
||||
log.Error("CreateProfileRepo: %v", err)
|
||||
ctx.Flash.Error(ctx.Tr("org.profile_repo_create_failed"))
|
||||
ctx.Redirect(org.AsUser().HomeLink())
|
||||
return
|
||||
}
|
||||
|
||||
// Redirect to edit the README
|
||||
ctx.Redirect(repo.Link() + "/_edit/main/README.md")
|
||||
}
|
||||
|
||||
@ -948,6 +948,7 @@ func registerWebRoutes(m *web.Router) {
|
||||
m.Get("/milestones", reqMilestonesDashboardPageEnabled, user.Milestones)
|
||||
m.Get("/milestones/{team}", reqMilestonesDashboardPageEnabled, user.Milestones)
|
||||
m.Post("/members/action/{action}", org.MembersAction)
|
||||
m.Post("/create-profile-repo", org.CreateProfileRepo)
|
||||
m.Get("/teams", org.Teams)
|
||||
}, context.OrgAssignment(context.OrgAssignmentOptions{RequireMember: true, RequireTeamMember: true}))
|
||||
|
||||
|
||||
@ -146,9 +146,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="tw-mt-4">
|
||||
<a class="ui primary button" href="{{AppSubUrl}}/repo/create?org={{.Org.ID}}&name=.profile">
|
||||
<form action="{{.OrgLink}}/create-profile-repo" method="post">{{.CsrfTokenHtml}}<button class="ui primary button" type="submit">
|
||||
{{svg "octicon-plus" 16}} {{ctx.Locale.Tr "org.create_profile_repo"}}
|
||||
</a>
|
||||
</button></form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user