Skip to content

pgmig/gitinfo

Repository files navigation

gitinfo

Get git repo metagata (lib) and generate gitinfo.json via go generate (cmd)

GoDoc codecov Build Status GoCard GitHub Release GitHub license

This package uses external git binary for creating a file with git metagata like

{
  "version": "v0.12.0-1-g99a5776",
  "repository": "git@github.com:pgmig/gitinfo.git",
  "modified": "2021-02-08T23:00:47+03:00"
}

This file (named `gitinfo.json by default) used later for

  • embedding with filesystems
  • showing project metagata

Install

go get github.com/pgmig/gitinfo/...

Usage

Create gitinfo.json

Run go:generate just before embedding:

// Generate gitinfo.json
//go:generate gitinfo ../../html

// Generate resource.go by [parcello](github.com/phogolabs/parcello)
//go:generate parcello -q -r -d ../../html

Read gitinfo.json

Read metadata from .gitinfo.json if it exists, fetch from git otherwise

var gi gitinfo.GitInfo
err = gitinfo.New(log, cfg).Make("cmd/", &gi)

Generate gitinfo.json for single dir

//go:generate gitinfo dir

Generate gitinfo.json files for dir/*/ dirs

Used when dir contains git submodules

//go:generate gitinfo dir/*

License

The MIT License (MIT), see LICENSE.

Copyright (c) 2019-2021 Aleksey Kovrizhkin lekovr+pgmig@gmail.com

About

Get git repo metagata (lib) and generate gitinfo.json via go generate (cmd)

Resources

License

Stars

Watchers

Forks

Packages

No packages published