Categorygithub.com/pgmig/gitinfo
modulepackage
0.12.1
Repository: https://github.com/pgmig/gitinfo.git
Documentation: pkg.go.dev

# README

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": "[email protected]: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 [email protected]

# Packages

No description provided by the author

# Functions

MkTime converts to time.Time result of `git show -s --format=format:%ct HEAD`.
New returns service object with config.

# Variables

ErrPathMustBeDir raised if given path is not directory.
ErrPathMustNotBeEmpty raised if given path is empty.

# Structs

Config holds all config vars.
GitInfo holds git repository metadata.
Service holds service data.

# Interfaces

File is an interface for FileSystem.Open func.
FileSystem holds all of used filesystem access methods.