mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-02 19:45:57 +01:00
Don't save if page is not modified.
This commit is contained in:
@@ -98,17 +98,27 @@ object WikiUtil {
|
|||||||
// write as file
|
// write as file
|
||||||
val cloned = Git.open(workDir)
|
val cloned = Git.open(workDir)
|
||||||
val file = new File(workDir, newPageName + ".md")
|
val file = new File(workDir, newPageName + ".md")
|
||||||
FileUtils.writeStringToFile(file, content, "UTF-8")
|
val added = if(!file.exists || FileUtils.readFileToString(file, "UTF-8") != content){
|
||||||
cloned.add.addFilepattern(file.getName).call
|
FileUtils.writeStringToFile(file, content, "UTF-8")
|
||||||
|
cloned.add.addFilepattern(file.getName).call
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
// delete file
|
// delete file
|
||||||
if(currentPageName != "" && currentPageName != newPageName){
|
val deleted = if(currentPageName != "" && currentPageName != newPageName){
|
||||||
cloned.rm.addFilepattern(currentPageName + ".md")
|
cloned.rm.addFilepattern(currentPageName + ".md")
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
// commit and push
|
// commit and push
|
||||||
cloned.commit.setAuthor(committer, committer + "@devnull").setMessage(message).call
|
if(added || deleted){
|
||||||
cloned.push.call
|
cloned.commit.setAuthor(committer, committer + "@devnull").setMessage(message).call
|
||||||
|
cloned.push.call
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user