Prevent empty commits and webmention spam
parent
09e3b77453
commit
580724e9f9
|
@ -127,6 +127,13 @@ func (g *Git) unsafeUpdateFile(filepath string, file string, message string) err
|
|||
if err != nil {
|
||||
return errors.New("failed to write to file")
|
||||
}
|
||||
status, err := w.Status()
|
||||
if err == nil && status.IsClean() {
|
||||
// No file changes, prevent empty commit
|
||||
return nil
|
||||
} else {
|
||||
err = nil
|
||||
}
|
||||
_, err = w.Add(filepath)
|
||||
if err != nil {
|
||||
return errors.New("failed to stage file")
|
||||
|
|
|
@ -138,7 +138,7 @@ func HandleWebmention(w http.ResponseWriter, r *http.Request) {
|
|||
e := saveWebmention(&Mention{
|
||||
Source: sourceUrl.String(),
|
||||
Target: targetUrl.String(),
|
||||
Date: time.Now().Format(time.RFC3339),
|
||||
Date: time.Now().Format("2006-01-02"),
|
||||
})
|
||||
if e != nil {
|
||||
fmt.Println("Failed to save webmention:", e.Error())
|
||||
|
|
Loading…
Reference in New Issue