gitmono

package module
v0.4.1 Latest Latest
Warning

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

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

README

gitmono

Git wrapper for monorepos

The following commands take one or more project paths as input (using the -p argument). The projects are any of the monorepo subdirectories and are considered separate projects residing in the monorepo. This tool provides commands to manage versioning of projects in monorepos.

Commands

diff command prints out the projects whose scope matches to at least one file included in the diff of the specified reference range.

version command extracts the latest version of the specified project.

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

init command releases a new version (0.1.0) for the specified projects that have never been released.

log command prints out the commits of the specified project.

Examples

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

mod2/0.1.0
mod1/0.1.0
  1. Get the latest version of a monorepo project:
gitmono version -p mod1

mod1/0.1.0
  1. Get the subset of modified monorepo projects:
gitmono diff -f head~1 -t head -p mod2 -p mod1

mod1
  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 {
	// Projects      []string
	DryRun        bool
	CommitScheme  string
	VersionPrefix 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, projects ...string) ([]string, error)

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

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 monorepo projects provided

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, projects ...string) ([]*git.Commit, error)

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

type Tagger

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

Tagger performs tag operation for a monorepo

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

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(project string) (*VersionedCommit, error)

GetCurrentVersion retrieves the current version for the specified project

func (*Versioner) InitVersion

func (v *Versioner) InitVersion(projects []string) ([]*VersionedCommit, error)

InitVersion identifies the projects with no initial version and performs release using initial version

func (*Versioner) ReleaseNewVersion added in v0.4.1

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

ReleaseNewVersion calculates the new version for the provided project 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