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:
parent
e5c96eee88
commit
43fbe3c6e2
@ -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 (
|
||||
|
@ -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 {
|
||||
|
3
hypha.go
3
hypha.go
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user