mirror of
https://dev.sigpipe.me/dashie/git.txt
synced 2025-10-06 02:22:41 +02:00
A flash message before Handle is useless and won't work as expected
This commit is contained in:
@@ -264,8 +264,6 @@ func View(ctx *context.Context) {
|
||||
repo, err := git.OpenRepository(repoPath)
|
||||
if err != nil {
|
||||
log.Warn("Could not open repository %s: %s", ctx.Gitxt.Gitxt.Hash, err)
|
||||
// TODO: The Flash isn't rendered
|
||||
ctx.Flash.Error(ctx.Tr("gitxt_git.could_not_open"))
|
||||
ctx.Handle(500, "GitxtView", err)
|
||||
return
|
||||
}
|
||||
@@ -274,8 +272,6 @@ func View(ctx *context.Context) {
|
||||
isEmpty, err := repo.IsEmpty()
|
||||
if err != nil || isEmpty {
|
||||
log.Warn("Empty repository or corrupted %s: %s", ctx.Gitxt.Gitxt.Hash, err)
|
||||
ctx.Flash.Error(ctx.Tr("gitxt_git.repo_corrupt_or_empty"))
|
||||
ctx.Handle(500, "GitxtView", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -283,8 +279,6 @@ func View(ctx *context.Context) {
|
||||
repoTreeEntries, err := gite.GetWalkTreeWithContent(repo, "/")
|
||||
if err != nil {
|
||||
log.Warn("Cannot get repository tree entries %s: %s", ctx.Gitxt.Gitxt.Hash, err)
|
||||
ctx.Flash.Error(ctx.Tr("gitxt_git.cannot_get_tree_entries"))
|
||||
ctx.Handle(500, "GitxtView", err)
|
||||
return
|
||||
|
||||
}
|
||||
@@ -406,7 +400,6 @@ func ListUploads(ctx *context.Context) {
|
||||
listOfGitxts, gitxtsCount, err := models.GetGitxts(opts)
|
||||
if err != nil {
|
||||
log.Warn("Cannot get Gitxts with opts %v, %s", opts, err)
|
||||
ctx.Flash.Error(ctx.Tr("gitxt_list.error_getting_list"))
|
||||
ctx.Handle(500, "ListUploads", err)
|
||||
return
|
||||
}
|
||||
@@ -439,7 +432,6 @@ func DeletePost(ctx *context.Context, f form.GitxtDelete) {
|
||||
|
||||
err := models.DeleteRepository(ctx.Gitxt.User.ID, ctx.Gitxt.Gitxt.ID)
|
||||
if err != nil {
|
||||
ctx.Flash.Error(ctx.Tr("gitxt_delete.error_deleting"))
|
||||
log.Warn("DeletePost.DeleteRepository: %v", err)
|
||||
ctx.JSONSuccess(map[string]interface{}{
|
||||
"error": ctx.Tr("gitxt_delete.error_deleting"),
|
||||
@@ -488,7 +480,6 @@ func Edit(ctx *context.Context) {
|
||||
repo, err := git.OpenRepository(repoPath)
|
||||
if err != nil {
|
||||
log.Warn("Could not open repository %s: %s", ctx.Gitxt.Gitxt.Hash, err)
|
||||
ctx.Flash.Error(ctx.Tr("gitxt_git.could_not_open"))
|
||||
ctx.Handle(500, "GitxtView", err)
|
||||
return
|
||||
}
|
||||
@@ -497,7 +488,6 @@ func Edit(ctx *context.Context) {
|
||||
isEmpty, err := repo.IsEmpty()
|
||||
if err != nil || isEmpty {
|
||||
log.Warn("Empty repository or corrupted %s: %s", ctx.Gitxt.Gitxt.Hash, err)
|
||||
ctx.Flash.Error(ctx.Tr("gitxt_git.repo_corrupt_or_empty"))
|
||||
ctx.Handle(500, "GitxtView", err)
|
||||
return
|
||||
}
|
||||
@@ -506,7 +496,6 @@ func Edit(ctx *context.Context) {
|
||||
repoTreeEntries, err := gite.GetWalkTreeWithContent(repo, "/")
|
||||
if err != nil {
|
||||
log.Warn("Cannot get repository tree entries %s: %s", ctx.Gitxt.Gitxt.Hash, err)
|
||||
ctx.Flash.Error(ctx.Tr("gitxt_git.cannot_get_tree_entries"))
|
||||
ctx.Handle(500, "GitxtView", err)
|
||||
return
|
||||
|
||||
@@ -594,7 +583,6 @@ func EditPost(ctx *context.Context, f form.GitxtEdit) {
|
||||
repo, err := git.OpenRepository(repoPath)
|
||||
if err != nil {
|
||||
log.Warn("Could not open repository %s: %s", ctx.Gitxt.Gitxt.Hash, err)
|
||||
ctx.Flash.Error(ctx.Tr("gitxt_git.could_not_open"))
|
||||
ctx.Handle(500, "GitxtEditPost", err)
|
||||
return
|
||||
}
|
||||
@@ -603,7 +591,6 @@ func EditPost(ctx *context.Context, f form.GitxtEdit) {
|
||||
isEmpty, err := repo.IsEmpty()
|
||||
if err != nil || isEmpty {
|
||||
log.Warn("Empty repository or corrupted %s: %s", ctx.Gitxt.Gitxt.Hash, err)
|
||||
ctx.Flash.Error(ctx.Tr("gitxt_git.repo_corrupt_or_empty"))
|
||||
ctx.Handle(500, "GitxtEditPost", err)
|
||||
return
|
||||
}
|
||||
|
@@ -5,23 +5,23 @@ import (
|
||||
"dev.sigpipe.me/dashie/git.txt/stuff/repository"
|
||||
log "gopkg.in/clog.v1"
|
||||
|
||||
"gopkg.in/libgit2/git2go.v25"
|
||||
"strings"
|
||||
"path"
|
||||
"github.com/Unknwon/com"
|
||||
"os"
|
||||
"dev.sigpipe.me/dashie/git.txt/stuff/tool"
|
||||
"dev.sigpipe.me/dashie/git.txt/stuff/gite"
|
||||
"dev.sigpipe.me/dashie/git.txt/stuff/tool"
|
||||
"github.com/Unknwon/com"
|
||||
"gopkg.in/libgit2/git2go.v25"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// DownloadArchive of repository
|
||||
func DownloadArchive(ctx *context.Context) {
|
||||
var (
|
||||
uri = ctx.Params("*")
|
||||
refName string
|
||||
ext string
|
||||
archivePath string
|
||||
archiveType string
|
||||
uri = ctx.Params("*")
|
||||
refName string
|
||||
ext string
|
||||
archivePath string
|
||||
archiveType string
|
||||
)
|
||||
|
||||
pathRepo := repository.RepoPath(ctx.RepoOwnerUsername, ctx.Gitxt.Gitxt.Hash)
|
||||
@@ -40,7 +40,7 @@ func DownloadArchive(ctx *context.Context) {
|
||||
ctx.Error(404)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
refName = strings.TrimSuffix(uri, ext)
|
||||
if refName != "master" {
|
||||
ctx.Handle(500, "Ref other than master not supported", nil)
|
||||
@@ -59,16 +59,14 @@ func DownloadArchive(ctx *context.Context) {
|
||||
repo, err := git.OpenRepository(pathRepo)
|
||||
if err != nil {
|
||||
log.Warn("Could not open repository %s: %s", ctx.Gitxt.Gitxt.Hash, err)
|
||||
ctx.Flash.Error(ctx.Tr("gitxt_git.could_not_open"))
|
||||
ctx.Handle(500, "GitxtEditPost", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Test if repository is empty
|
||||
isEmpty, err := repo.IsEmpty();
|
||||
isEmpty, err := repo.IsEmpty()
|
||||
if err != nil || isEmpty {
|
||||
log.Warn("Empty repository or corrupted %s: %s", ctx.Gitxt.Gitxt.Hash, err)
|
||||
ctx.Flash.Error(ctx.Tr("gitxt_git.repo_corrupt_or_empty"))
|
||||
ctx.Handle(500, "GitxtEditPost", err)
|
||||
return
|
||||
}
|
||||
@@ -116,4 +114,4 @@ func DownloadArchive(ctx *context.Context) {
|
||||
}
|
||||
|
||||
ctx.ServeFile(archivePath, ctx.Gitxt.Gitxt.Hash+"-"+refName+ext)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user