Skip to content

Commit e2233cd

Browse files
committed
git-annex: show info message for hidden branches
1 parent 5bfe873 commit e2233cd

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

modules/annex/annex.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,9 @@ func IsAnnexed(blob *git.Blob) (bool, error) {
152152
}
153153
return true, nil
154154
}
155+
156+
// IsAnnexRepo determines if repo is a git-annex enabled repository
157+
func IsAnnexRepo(repo *git.Repository) bool {
158+
_, _, err := git.NewCommand(repo.Ctx, "annex", "info").RunStdString(&git.RunOpts{Dir: repo.Path})
159+
return err == nil
160+
}

routers/web/repo/branch.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
git_model "code.gitea.io/gitea/models/git"
1616
repo_model "code.gitea.io/gitea/models/repo"
1717
"code.gitea.io/gitea/models/unit"
18+
"code.gitea.io/gitea/modules/annex"
1819
"code.gitea.io/gitea/modules/base"
1920
"code.gitea.io/gitea/modules/context"
2021
"code.gitea.io/gitea/modules/git"
@@ -45,6 +46,10 @@ func Branches(ctx *context.Context) {
4546
ctx.Data["PageIsViewCode"] = true
4647
ctx.Data["PageIsBranches"] = true
4748

49+
if annex.IsAnnexRepo(ctx.Repo.GitRepo) {
50+
ctx.Flash.Info("This repository is a git-annex repository, the git-annex branch as well as all synced/* branches are hidden to avoid accidental changes to or from them.", true)
51+
}
52+
4853
page := ctx.FormInt("page")
4954
if page <= 1 {
5055
page = 1

templates/repo/branch/list.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{template "base/head" .}}
2-
<div role="main" aria-label="{{.Title}}" class="page-content ui repository branches">
2+
<div role="main" aria-label="{{.Title}}" class="page-content repository branches">
33
{{template "repo/header" .}}
44
<div class="ui container">
55
{{template "base/alert" .}}

0 commit comments

Comments
 (0)