mirror of
https://github.com/beego/bee.git
synced 2025-06-26 19:10:19 +00:00
Revert "Backup only when content changes"
This reverts commit f601e441f3
.
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
package beegopro
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/beego/bee/internal/pkg/utils"
|
||||
@ -11,7 +10,6 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@ -190,41 +188,3 @@ func getModelType(orm string) (inputType, goType, mysqlType, tag string) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func FileContentChange(org,new string) bool {
|
||||
if org == "" {
|
||||
return false
|
||||
}
|
||||
var orgContent,newContent string
|
||||
jump := false
|
||||
// expect tab character and blank space and "import(***)"
|
||||
reg := regexp.MustCompile("\\s+")
|
||||
for i, s := range strings.Split(org, "\n") {
|
||||
if s == "import (" {
|
||||
jump = true
|
||||
}
|
||||
if jump && s == ")" {
|
||||
jump = false
|
||||
}
|
||||
if i > 2 && !jump {
|
||||
orgContent += reg.ReplaceAllString(s, "")
|
||||
}
|
||||
}
|
||||
for i, s := range strings.Split(new, "\n") {
|
||||
if s == "import (" {
|
||||
jump = true
|
||||
}
|
||||
if jump && s == ")" {
|
||||
jump = false
|
||||
}
|
||||
if i > 2 && !jump {
|
||||
newContent += reg.ReplaceAllString(s, "")
|
||||
}
|
||||
}
|
||||
orgMd5 := md5.Sum([]byte(orgContent))
|
||||
newMd5:= md5.Sum([]byte(newContent))
|
||||
if orgMd5 != newMd5 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
Reference in New Issue
Block a user