1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-13 05:50:27 +00:00

Ignore edits that do not edit anything

This commit is contained in:
bouncepaw 2021-01-21 19:21:34 +05:00
parent e5c96eee88
commit 43fbe3c6e2
3 changed files with 15 additions and 0 deletions

View File

@ -82,6 +82,12 @@ func RecentChanges(n int) string {
return templates.RecentChangesHTML(entries, n)
}
// FileChanged tells you if the file has been changed.
func FileChanged(path string) bool {
_, err := gitsh("diff", "--exit-code", path)
return err != nil
}
// Revisions returns slice of revisions for the given hypha name.
func Revisions(hyphaName string) ([]Revision, error) {
var (

View File

@ -109,6 +109,12 @@ func (hop *HistoryOp) Apply() *HistoryOp {
return hop
}
// Abort aborts the history operation.
func (hop *HistoryOp) Abort() *HistoryOp {
gitMutex.Unlock()
return hop
}
// WithMsg sets what message will be used for the future commit. If user message exceeds one line, it is stripped down.
func (hop *HistoryOp) WithMsg(userMsg string) *HistoryOp {
for _, ch := range userMsg {

View File

@ -88,6 +88,9 @@ func uploadHelp(hop *history.HistoryOp, hyphaName, ext string, data []byte, u *u
hyphae.IncrementCount()
}
*originalFullPath = fullPath
if hop.Type == history.TypeEditText && !history.FileChanged(fullPath) {
return hop.Abort()
}
return hop.WithFiles(fullPath).
WithUser(u).
Apply()