~kornellapacz/gmnigit

6068fd5db5778ba2176525e836de75b20569c616 — Korneliusz Łapacz 5 months ago fe2e857
convert README.md to .gmi and write it to index.gmi
3 files changed, 31 insertions(+), 2 deletions(-)

M go.mod
M go.sum
M main.go
M go.mod => go.mod +4 -1
@@ 4,4 4,7 @@ replace github.com/go-git/go-git/v5 v5.3.1 => github.com/kornellapacz/go-git/v5 

go 1.16

require github.com/go-git/go-git/v5 v5.3.1
require (
	git.tdem.in/tdemin/gmnhg v0.1.1
	github.com/go-git/go-git/v5 v5.3.1
)

M go.sum => go.sum +5 -0
@@ 1,3 1,5 @@
git.tdem.in/tdemin/gmnhg v0.1.1 h1:TEGzY+w1YkahwgqEyASdHDi1UJuFgoxSE2fao6a1qx8=
git.tdem.in/tdemin/gmnhg v0.1.1/go.mod h1:dMGOEoFj7QRX7h/x1fkrnmdIFeT4ymkjmqK1htuTzsQ=
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk=
github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0=


@@ 25,6 27,8 @@ github.com/go-git/go-billy/v5 v5.1.0 h1:4pl5BV4o7ZG/lterP4S6WzJ6xr49Ba5ET9ygheTY
github.com/go-git/go-billy/v5 v5.1.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
github.com/go-git/go-git-fixtures/v4 v4.0.2-0.20200613231340-f56387b50c12 h1:PbKy9zOy4aAKrJ5pibIRpVO2BXnK1Tlcg+caKI7Ox5M=
github.com/go-git/go-git-fixtures/v4 v4.0.2-0.20200613231340-f56387b50c12/go.mod h1:m+ICp2rF3jDhFgEZ/8yziagdT1C+ZpZcrJjappBCDSw=
github.com/gomarkdown/markdown v0.0.0-20201024011455-45c732cc8a6b h1:Om9FdD4lzIJELyJxwr9EWSjaG6GMUNS3iebnhrGevhI=
github.com/gomarkdown/markdown v0.0.0-20201024011455-45c732cc8a6b/go.mod h1:aii0r/K0ZnHv7G0KF7xy1v0A7s2Ljrb5byB7MO5p6TU=
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=


@@ 62,6 66,7 @@ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJy
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI=
github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0=
golang.org/dl v0.0.0-20190829154251-82a15e2f2ead/go.mod h1:IUMfjQLJQd4UTqG1Z90tenwKoCX93Gn3MAQJMOSBsDQ=
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 h1:It14KIkyBFYkHkwZ7k45minvA9aorojkyjGk9KJ5B/w=

M main.go => main.go +22 -1
@@ 7,6 7,7 @@ import (
	"strings"
	"text/template"

	gemini "git.tdem.in/tdemin/gmnhg"
	"github.com/go-git/go-git/v5"
	"github.com/go-git/go-git/v5/plumbing/object"
)


@@ 173,7 174,27 @@ func main() {
		indexFile.WriteString("```\ngit clone " + strings.TrimSpace(string(url)) + "\n```\n\n")
	}

	indexFile.WriteString("=> commits/\n=> files/\n")
	indexFile.WriteString("=> commits/\n=> files/\n\n")

	// convert README.md to gemini and write it to index.gmi in repository root
	text, err := os.ReadFile(filepath.Join(filesPath, "README.md"))

	if err != nil {
		if os.IsNotExist(err) {
			log.Println("README.md not found in your repository")

			check(indexFile.Close())
			return
		}

		log.Fatal(err)
	}

	check(err)
	geminiContent, _, err := gemini.RenderMarkdown(text, gemini.WithMetadata)
	check(err)

	indexFile.Write(geminiContent)

	check(indexFile.Close())
}