Documentation ¶
Index ¶
- Constants
- func Bump(input string, component int) (bumped string, err error)
- func CheckClean(rootDirectory string) error
- func CommandIn(workingDirectory, program string, arguments ...string) *exec.Cmd
- func PullSubrepo(rootDirectory, subDirectory string) error
- func ReplacePattern(input []byte, format, change string) (modified []byte, changed string, err error)
- func ReplaceValue(object []byte, field string, changed interface{}) (modified []byte, err error)
- func UpdateAPI(API apiInfo, absolutePath string, permissions os.FileMode, ...) error
- func UpdateDiscos() (names []string, err error)
- func UpdateFile(directory, name string, update func([]byte) ([]byte, string, error)) (info string, err error)
- func Version(input string) (numbers []string, err error)
Constants ¶
const MaxInt = int(^uint(0) >> 1)
MaxInt gives the maximum value of the machine-dependent default integer type. (Standard library constants are specific to machine-independent types.)
Variables ¶
This section is empty.
Functions ¶
func Bump ¶
Bump increments a `component` of the first three-part version number '#.#.#' found in `input`, returning the `bumped` version string alone.
func CheckClean ¶
CheckClean verifies that the given repository `rootDirectory` contains no uncommitted changes.
func CommandIn ¶
CommandIn returns the `exec.Cmd` struct to execute `program` with `arguments` in `workingDirectory`.
func PullSubrepo ¶
PullSubrepo pulls external changes for the subrepository `subDirectory` in the repository `rootDirectory`, using the git-subrepo tool. It should not be run concurrently with other operations modifying files in the repository.
func ReplacePattern ¶
func ReplacePattern(input []byte, format, change string) (modified []byte, changed string, err error)
ReplacePattern replaces the first instance in `input` of a pattern corresponding to a `format` string, by a `change` string. It returns a non-nil error if no match appears; otherwise, it returns the `modified` input and the `changed` portion obtained by expanding any template variables in the `change` string (see: https://golang.org/pkg/regexp/).
The `format` string is assumed to contain string substitutions denoted by `%s` and numeric substitutions denoted by `%v`. The corresponding regexp pattern is derived by quoting regexp metacharacters, matching string substitutions to shortest corresponding substrings without newlines, and matching integer substitutions to longest corresponding nonempty digit substrings.
func ReplaceValue ¶
ReplaceValue replaces the value of a top-level `field` in a JSON `object` with a `changed` value, returning the `modified` object.
This implementation works around the lack of order-preserving (un)marshaling in the standard library `json` package, by the most straightforward means available for our purposes: It uses the standard library decoder to locate the boundaries of the existing value, replacing it with an encoding of the changed value with no extraneous formatting, and leaving the remainder of the object encoding unchanged.
Note that Go developers have rejected order-preserving capabilities in the standard library with assertions that JSON is not a human-readable format (the standard library's support for indentation notwithstanding). Compare the second sentence of http://www.json.org, which states that "[JSON] is easy for humans to read and write."
func UpdateAPI ¶
func UpdateAPI(API apiInfo, absolutePath string, permissions os.FileMode, updateChannel chan string) error
UpdateAPI reads the Discovery doc for an `API` indexed by the live Discovery service and updates the corresponding cached file in the top-level 'discoveries' directory at `absolutePath` with `permissions`, sending the intended file name to an `updateChannel` regardless of any error in the update.
To avoid unnecessary updates due to nondeterministic JSON field ordering from live Discovery docs for some APIs, UpdateAPI updates only files with meaningful changes, as determined by deep equality of maps parsed from JSON, ignoring changes to top-level `etag` and `revision` fields.
func UpdateDiscos ¶
UpdateDiscos updates local Discovery doc files for all APIs indexed by the live Discovery service, in a top-level directory 'discoveries', which must exist; and returns the absolute `names` of updated files.
Types ¶
This section is empty.