Change summary
main.go | 32 ++++++--------------------------
1 file changed, 6 insertions(+), 26 deletions(-)
Detailed changes
@@ -25,7 +25,6 @@ import (
"gioui.org/unit"
"gioui.org/widget/material"
"github.com/adrg/frontmatter"
- "github.com/go-git/go-git/v5"
flag "github.com/spf13/pflag"
"gopkg.in/yaml.v3"
)
@@ -55,7 +54,7 @@ func main() {
postTitle, postDate, postContent := getPostInfo(*flagInput)
postReadTime := getReadTime(postContent)
siteTitle := getSiteTitle()
- dateEdited := getGitDate(*flagInput)
+ dateEdited := getEditDate(*flagInput)
collection := fontCollection()
@@ -403,33 +402,14 @@ func getSiteTitle() string {
return t.Title
}
-// Get the date the post was last edited
-func getGitDate(input string) string {
- if _, err := os.Stat(input); os.IsNotExist(err) {
- fmt.Println("Error: Input file does not exist")
- os.Exit(1)
- }
-
- repo, err := git.PlainOpenWithOptions(".", &git.PlainOpenOptions{DetectDotGit: true})
- if err != nil {
- fmt.Println("Error: Could not open git repository")
- fmt.Println(err)
- os.Exit(1)
- }
-
- commitIter, err := repo.Log(&git.LogOptions{FileName: &input})
- if err != nil {
- fmt.Println("Error: Could not get git history")
- fmt.Println(err)
- os.Exit(1)
- }
-
- commit, err := commitIter.Next()
+// Get the date the post was last edited using the file metadata
+func getEditDate(input string) string {
+ fileInfo, err := os.Stat(input)
if err != nil {
- fmt.Println("Error: Could not get git history")
+ fmt.Println("Error: Could not get file info")
fmt.Println(err)
os.Exit(1)
}
- return commit.Committer.When.Format("2006-01-02")
+ return fileInfo.ModTime().Format("2006-01-02")
}