fix: switch org wiki tab to .profile wiki sidecars #595

Closed
jmiller wants to merge 1 commits from fix/org-wiki-profile-sidecars into main
4 changed files with 22 additions and 18 deletions
+11 -9
View File
@@ -157,7 +157,8 @@ func Wiki(ctx *context.Context) {
ctx.HTML(http.StatusOK, tplOrgWiki)
}
// findOrgWikiCommit locates the convention wiki repo and returns its HEAD commit.
// findOrgWikiCommit locates the profile repo's wiki and returns its HEAD commit.
// The org wiki lives in the .wiki.git sidecar of the profile repo (e.g. .profile.wiki.git).
func findOrgWikiCommit(ctx *context.Context, orgID int64, repoName string) (*repo_model.Repository, *git.Commit) {
dbRepo, err := repo_model.GetRepositoryByName(ctx, orgID, repoName)
if err != nil {
@@ -167,19 +168,20 @@ func findOrgWikiCommit(ctx *context.Context, orgID int64, repoName string) (*rep
return nil, nil
}
if dbRepo.IsEmpty {
// Open the wiki git repo (.wiki.git sidecar), not the main repo.
wikiGitRepo, err := gitrepo.RepositoryFromRequestContextOrOpen(ctx, dbRepo.WikiStorageRepo())
if err != nil {
// Wiki repo doesn't exist yet — not an error, just no wiki.
return nil, nil
}
gitRepo, err := gitrepo.RepositoryFromRequestContextOrOpen(ctx, dbRepo)
if err != nil {
log.Error("findOrgWikiCommit: OpenRepository(%s): %v", dbRepo.FullName(), err)
return nil, nil
branch := dbRepo.DefaultWikiBranch
if branch == "" {
branch = "main"
}
commit, err := gitRepo.GetBranchCommit(dbRepo.DefaultBranch)
commit, err := wikiGitRepo.GetBranchCommit(branch)
if err != nil {
log.Error("findOrgWikiCommit: GetBranchCommit(%s, %s): %v", dbRepo.FullName(), dbRepo.DefaultBranch, err)
log.Error("findOrgWikiCommit: GetBranchCommit wiki(%s, %s): %v", dbRepo.FullName(), branch, err)
return nil, nil
}
+7 -5
View File
@@ -137,8 +137,8 @@ type PrepareOwnerHeaderResult struct {
const (
RepoNameProfilePrivate = ".profile-private"
RepoNameProfile = ".profile"
RepoNameWikiPublic = "wiki"
RepoNameWikiPrivate = "wiki-private"
RepoNameWikiPublic = ".profile"
RepoNameWikiPrivate = ".profile-private"
)
func RenderUserOrgHeader(ctx *context.Context) (result *PrepareOwnerHeaderResult, err error) {
@@ -209,11 +209,13 @@ func loadHeaderCount(ctx *context.Context) error {
return nil
}
// OrgWikiRepoExists checks whether a convention wiki repo exists and is non-empty.
// OrgWikiRepoExists checks whether a profile repo's wiki exists and has content.
func OrgWikiRepoExists(ctx *context.Context, ownerID int64, repoName string) bool {
dbRepo, err := repo_model.GetRepositoryByName(ctx, ownerID, repoName)
if err != nil || dbRepo.IsEmpty {
if err != nil {
return false
}
return true
// Check if the wiki sidecar repo exists by trying to get its default branch.
_, err = gitrepo.GetDefaultBranch(ctx, dbRepo.WikiStorageRepo())
return err == nil
}
+2 -2
View File
@@ -68,11 +68,11 @@
<div class="field">
<div class="ui radio checkbox">
<input class="enable-system-radio" name="wiki_mode" type="radio" value="" data-context="#external_wiki_box" data-target="#internal_wiki_box" {{if eq .Org.WikiMode ""}}checked{{end}}>
<label>Internal wiki (uses <code>wiki</code> / <code>wiki-private</code> repos)</label>
<label>Internal wiki (uses <code>.profile</code> / <code>.profile-private</code> repo wikis)</label>
</div>
</div>
<div id="internal_wiki_box" class="field tw-pl-4 {{if ne .Org.WikiMode ""}}disabled{{end}}">
<p class="help">Create repos named <code>wiki</code> (public) and/or <code>wiki-private</code> (members-only) under this organization.</p>
<p class="help">Enable the wiki on <code>.profile</code> (public) and/or <code>.profile-private</code> (members-only) repos.</p>
</div>
<div class="field">
<div class="ui radio checkbox">
+2 -2
View File
@@ -11,8 +11,8 @@
This organization doesn't have a wiki yet.
</div>
<p class="tw-text-center">
Create a repository named <code>wiki</code> (public) or <code>wiki-private</code> (members-only)
with markdown files to get started.
Enable the wiki on the <code>.profile</code> (public) or <code>.profile-private</code> (members-only)
repository to get started.
</p>
</div>
{{else}}