mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-06-10 14:44:06 +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)
|
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.
|
// Revisions returns slice of revisions for the given hypha name.
|
||||||
func Revisions(hyphaName string) ([]Revision, error) {
|
func Revisions(hyphaName string) ([]Revision, error) {
|
||||||
var (
|
var (
|
||||||
|
@ -109,6 +109,12 @@ func (hop *HistoryOp) Apply() *HistoryOp {
|
|||||||
return hop
|
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.
|
// 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 {
|
func (hop *HistoryOp) WithMsg(userMsg string) *HistoryOp {
|
||||||
for _, ch := range userMsg {
|
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()
|
hyphae.IncrementCount()
|
||||||
}
|
}
|
||||||
*originalFullPath = fullPath
|
*originalFullPath = fullPath
|
||||||
|
if hop.Type == history.TypeEditText && !history.FileChanged(fullPath) {
|
||||||
|
return hop.Abort()
|
||||||
|
}
|
||||||
return hop.WithFiles(fullPath).
|
return hop.WithFiles(fullPath).
|
||||||
WithUser(u).
|
WithUser(u).
|
||||||
Apply()
|
Apply()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user