gitmono

package module
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2022 License: MIT Imports: 6 Imported by: 0

README

Go Report Card

gitmono

Git wrapper for monorepos

This tool provides commands to manage versioning of projects in monorepos.

All commands accept the monorepo project to operate on, using the -p flag. When none is specified, the flag defaults to . that enables the tool for any repository type (also non-monorepo). The project value is expected to match a subdirectory of the project from the root path, to support diff and log commands.

Commands

diff command prints out the modified files for the specified git reference range that match the project subdirectory.

log command prints out the commits for the specified git reference range that match project subdirectory.

init command releases and prints the initial version (0.1.0) for the specified project, if it has never been released.

version command prints the latest version of the specified project.

release command releases and prints a new version of the specified project, after looking up for a version bump command in the commits that reference files of that project.

Examples

  1. Initialise the version of all monorepo projects:
gitmono init --version-prefix=v -p mod1

v0.1.0
  1. Get the latest version of a monorepo project:
gitmono version -p mod1 --version-prefix=v

v0.1.0
  1. Get the subset of modified monorepo projects:
gitmono diff -f head~1 -t head -p mod1

mod1/go.mod
  1. Release new version for a modified monorepo project:
gitmono release -p mod1 --commit-scheme=conventional --version-prefix=v

mod1/v0.2.0
  1. Get log of commits relevant to a monorepo project:
gitmono log -p mod1 -f head~2 -t head

7fd4cd0d6141b3cbc3c4f0a2206090140d2d7722 fix: mod1 modified

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DryRun        bool
	CommitScheme  string
	VersionPrefix string
	PrintTag      bool
	Project       string
}

Config defines generic configuration applying to multiple commands

type Differ

type Differ struct {
	// contains filtered or unexported fields
}

Differ performs diff operation for a monorepo.

func NewDiffer

func NewDiffer(mono *GitMono) *Differ

NewDiffer creates a new differ instance.

func (*Differ) Diff

func (d *Differ) Diff(from, to string) ([]string, error)

Diff performs diff for the provided git references range Matches changed files to the provided monorepo project and return the list of files

type GitMono

type GitMono struct {
	// contains filtered or unexported fields
}

GitMono contains repository instance and command parameters

func OpenRepo added in v0.2.0

func OpenRepo(path string, config *Config) (*GitMono, error)

OpenRepo open a git repository and returns the monorepo wrapper

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger performs log operation for the specifed monorepo project

func NewLogger

func NewLogger(mono *GitMono) *Logger

NewLogger creates a new logger instance

func (*Logger) CommitHashByRevision

func (l *Logger) CommitHashByRevision(rev string) (string, error)

CommitHashByRevision lookup the commit hash for a revision/reference.

func (*Logger) Log

func (l *Logger) Log(from, to string) ([]*git.Commit, error)

Log performs log operation for the provided git references range and monorepo project

type Tagger

type Tagger struct {
	// contains filtered or unexported fields
}

Tagger performs tag operation for a monorepo

func NewTagger added in v0.6.0

func NewTagger(mono *GitMono) *Tagger

NewTagger creates a new tagger instance

func (*Tagger) CreateTag added in v0.4.1

func (t *Tagger) CreateTag(versionedCommit *VersionedCommit) error

CreateTag create a tag on the provided commit

func (*Tagger) Tags

func (t *Tagger) Tags() ([]string, error)

Tags retrieves all repository tags

type VersionedCommit

type VersionedCommit struct {
	CommitID      string
	Project       string
	VersionPrefix string
	Version       *version.Version
}

VersionedCommit points a commit that is assigned a version

func (*VersionedCommit) GetTag

func (vc *VersionedCommit) GetTag() string

GetTag returns the tag to version a commit with

func (*VersionedCommit) GetVersion added in v0.6.0

func (vc *VersionedCommit) GetVersion() string

GetVersion returns the version part of the tag

type Versioner

type Versioner struct {
	// contains filtered or unexported fields
}

Versioner combines git commands to read and write releases

func NewVersioner

func NewVersioner(mono *GitMono) *Versioner

NewVersioner creates a new versioner instance

func (*Versioner) GetCurrentVersion added in v0.4.1

func (v *Versioner) GetCurrentVersion() (*VersionedCommit, error)

GetCurrentVersion retrieves the current version

func (*Versioner) InitVersion

func (v *Versioner) InitVersion(commitID string) (*VersionedCommit, error)

InitVersion identifies checks if project has version and releases the initial version

func (*Versioner) ReleaseNewVersion added in v0.4.1

func (v *Versioner) ReleaseNewVersion(commitID string) (*VersionedCommit, error)

ReleaseNewVersion calculates the new version and performs release

Returns an error if there are no new commits for the provided project

Directories

Path Synopsis
cmd
gitmono command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL