Skip to content

Commit

Permalink
git-annex: show info message for hidden branches
Browse files Browse the repository at this point in the history
  • Loading branch information
matrss committed Nov 7, 2023
1 parent 5bfe873 commit e2233cd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions modules/annex/annex.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,9 @@ func IsAnnexed(blob *git.Blob) (bool, error) {
}
return true, nil
}

// IsAnnexRepo determines if repo is a git-annex enabled repository
func IsAnnexRepo(repo *git.Repository) bool {
_, _, err := git.NewCommand(repo.Ctx, "annex", "info").RunStdString(&git.RunOpts{Dir: repo.Path})
return err == nil
}
5 changes: 5 additions & 0 deletions routers/web/repo/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
git_model "code.gitea.io/gitea/models/git"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unit"
"code.gitea.io/gitea/modules/annex"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/git"
Expand Down Expand Up @@ -45,6 +46,10 @@ func Branches(ctx *context.Context) {
ctx.Data["PageIsViewCode"] = true
ctx.Data["PageIsBranches"] = true

if annex.IsAnnexRepo(ctx.Repo.GitRepo) {
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)
}

page := ctx.FormInt("page")
if page <= 1 {
page = 1
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/branch/list.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{template "base/head" .}}
<div role="main" aria-label="{{.Title}}" class="page-content ui repository branches">
<div role="main" aria-label="{{.Title}}" class="page-content repository branches">
{{template "repo/header" .}}
<div class="ui container">
{{template "base/alert" .}}
Expand Down

0 comments on commit e2233cd

Please sign in to comment.