feat: add .mokogitea directory support alongside .gitea and .github

MokoGitea now recognizes .mokogitea/ as a first-class directory for:
- Workflow files (.mokogitea/workflows/) with highest priority
- README rendering from .mokogitea/ directory
- Repository template files (.mokogitea/template)
- Vendor path exclusion

The .gitea and .github directories remain supported for compatibility.

Authored-by: Moko Consulting
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan Miller
2026-05-15 20:19:43 -05:00
parent ddbd592c2f
commit 96eb394a17
6 changed files with 24 additions and 14 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ func IsVendor(treePath string) bool {
case ".gitignore", ".gitattributes", ".gitmodules":
return false
}
if strings.HasPrefix(treePath, ".github/") || strings.HasPrefix(treePath, ".gitea/") {
if strings.HasPrefix(treePath, ".github/") || strings.HasPrefix(treePath, ".gitea/") || strings.HasPrefix(treePath, ".mokogitea/") {
return false
}
return true
+1 -1
View File
@@ -34,7 +34,7 @@ var (
Enabled: true,
DefaultActionsURL: defaultActionsURLGitHub,
SkipWorkflowStrings: []string{"[skip ci]", "[ci skip]", "[no ci]", "[skip actions]", "[actions skip]"},
WorkflowDirs: []string{".gitea/workflows", ".github/workflows"},
WorkflowDirs: []string{".mokogitea/workflows", ".gitea/workflows", ".github/workflows"},
MaxRerunAttempts: defaultMaxRerunAttempts,
}
)
+1 -1
View File
@@ -112,7 +112,7 @@ func Test_WorkflowDirs(t *testing.T) {
{
name: "default",
iniStr: `[actions]`,
wantDirs: []string{".gitea/workflows", ".github/workflows"},
wantDirs: []string{".mokogitea/workflows", ".gitea/workflows", ".github/workflows"},
},
{
name: "single dir",
+9 -5
View File
@@ -32,7 +32,7 @@ import (
//
// FIXME: There has to be a more efficient way of doing this
func findReadmeFileInEntries(ctx *context.Context, parentDir string, entries []*git.TreeEntry, tryWellKnownDirs bool) (string, *git.TreeEntry, error) {
docsEntries := make([]*git.TreeEntry, 3) // (one of docs/, .gitea/ or .github/)
docsEntries := make([]*git.TreeEntry, 4) // (one of docs/, .mokogitea/, .gitea/ or .github/)
for _, entry := range entries {
if tryWellKnownDirs && entry.IsDir() {
// as a special case for the top-level repo introduction README,
@@ -44,14 +44,18 @@ func findReadmeFileInEntries(ctx *context.Context, parentDir string, entries []*
if entry.Name() == "docs" || docsEntries[0] == nil {
docsEntries[0] = entry
}
case ".gitea":
if entry.Name() == ".gitea" || docsEntries[1] == nil {
case ".mokogitea":
if entry.Name() == ".mokogitea" || docsEntries[1] == nil {
docsEntries[1] = entry
}
case ".github":
if entry.Name() == ".github" || docsEntries[2] == nil {
case ".gitea":
if entry.Name() == ".gitea" || docsEntries[2] == nil {
docsEntries[2] = entry
}
case ".github":
if entry.Name() == ".github" || docsEntries[3] == nil {
docsEntries[3] = entry
}
}
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ import (
)
func TestFindReadmeFileInEntriesWithSymlinkInSubfolder(t *testing.T) {
for _, subdir := range []string{".github", ".gitea", "docs"} {
for _, subdir := range []string{".github", ".gitea", ".mokogitea", "docs"} {
t.Run(subdir, func(t *testing.T) {
repoPath := t.TempDir()
stdin := fmt.Sprintf(`commit refs/heads/master
+11 -5
View File
@@ -140,12 +140,18 @@ func (gt *giteaTemplateFileMatcher) Match(s string) bool {
}
func readGiteaTemplateFile(tmpDir string) (*giteaTemplateFileMatcher, error) {
templateRelPath := filepath.Join(".gitea", "template")
content, err := util.ReadRegularPathFile(tmpDir, templateRelPath, 1024*1024)
if err != nil {
return nil, util.Iif(errors.Is(err, util.ErrNotRegularPathFile), os.ErrNotExist, err)
// MokoGitea: check .mokogitea/template first, then fall back to .gitea/template
for _, dir := range []string{".mokogitea", ".gitea"} {
templateRelPath := filepath.Join(dir, "template")
content, err := util.ReadRegularPathFile(tmpDir, templateRelPath, 1024*1024)
if err == nil {
return newGiteaTemplateFileMatcher(templateRelPath, content), nil
}
if !errors.Is(err, util.ErrNotRegularPathFile) && !os.IsNotExist(err) {
return nil, err
}
}
return newGiteaTemplateFileMatcher(templateRelPath, content), nil
return nil, os.ErrNotExist
}
func substGiteaTemplateFile(ctx context.Context, tmpDir, tmpDirSubPath string, templateRepo, generateRepo *repo_model.Repository) error {