gobump

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2020 License: MIT Imports: 17 Imported by: 1

README

= gobump

`gobump` bumps up program version by rewriting `version`-like variable/constant values in the Go source code following http://semver.org/[SemVer].

== USAGE

    Usage: gobump (major|minor|patch|up|set <version>|show) [-w] [-v] [<path>]

    Commands:
      major             bump major version up
      minor             bump minor version up
      patch             bump patch version up
      up                bump up with prompt
      set <version>     set exact version (no increments)
      show              only show the versions (implies -v)

    Flags:
      -v=false: show the resulting version values
      -w=false: write result to (source) file instead of stdout

== EXAMPLE

Suppose you have a source file:

[source,go]
----
package main

const version = "2.3.4" // must follow semver spec
----

If you run

    gobump minor

you will get:

[source,go]
----
package main

const version = "2.4.0"
----

Use `-w` to rewrite the file in-place.

Other options:

    gobump major     # 2.3.4 -> 3.0.0
    gobump minor     # 2.3.4 -> 2.4.0
    gobump patch     # 2.3.4 -> 2.3.5
    gobump set 5.5.5 # 2.3.4 -> 5.5.5

== INSTALL

```
go get github.com/x-motemen/gobump/cmd/gobump
```

== AUTHOR

motemen

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(argv []string, outStream, errStream io.Writer) error

Run the gobump

Types

type Config

type Config struct {
	// Increments major version. Precedes MinorDelta and PatchDelta.
	MajorDelta uint64
	// Increments minor version. Precedes PatchDelta.
	MinorDelta uint64
	// Increments patch version.
	PatchDelta uint64
	// Sets the version to exact version (no bump). Precedes all of above delta's.
	Exact string
	// The pattern of "version" variable/constants. Defaults to /^(?i)version$/.
	NamePattern *regexp.Regexp
	// Prompt the bump up target (major, minor or patch)
	Prompt bool
	// Default version in the case none was set. Defaults to "0.0.0".
	Default string
}

Config is the entrypoint of gobump.

func (Config) Process

func (conf Config) Process(filename string, src interface{}) ([]byte, map[string]string, error)

Process takes a Go source file and bumps version declaration according to conf. Returns the modified code and a map from identifiers to updated versions and an error, if any.

func (Config) ProcessNode

func (conf Config) ProcessNode(fset *token.FileSet, node ast.Node) (versions map[string]string, nodeErr error)

ProcessNode finds and bumps up "version" value found inside given node. returns the map from identifier names rewrote inside node to version string.

type Gobump

type Gobump struct {
	Write, Verbose, Raw, Show bool
	Target                    string

	Config    Config
	OutStream io.Writer
}

Gobump is main application struct

func (*Gobump) Run

func (gb *Gobump) Run() (map[string]map[string]string, error)

Run the gobump

type NodeErr

type NodeErr struct {
	Fset *token.FileSet
	Pos  token.Pos
	Msg  string
}

NodeErr represents for a ProcessNode error.

func (NodeErr) Error

func (e NodeErr) Error() string

Directories

Path Synopsis
cmd
gobump
gobump bumps up program version by rewriting `version`-like variable/constant values in the Go source code.
gobump bumps up program version by rewriting `version`-like variable/constant values in the Go source code.

Jump to

Keyboard shortcuts

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