DataDog/glock

Name: glock

Owner: Datadog, Inc.

Description: Forked due to https://github.com/robfig/glock/pull/34 (Keeping it stable for now)

Forked from: robfig/glock

Created: 2016-08-12 15:53:45.0

Updated: 2016-08-12 16:04:30.0

Pushed: 2017-02-20 10:27:21.0

Homepage:

Size: 93

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Glock is a command-line tool to lock dependencies to specific revisions, using a version control hook to keep those revisions in sync across a team.

Overview

Glock provides 2 commands and a version control hook:

GLOCKFILEs are simple text files that record a repo roots's revision, e.g.

ucket.org/tebeka/selenium 02df1758050f
.google.com/p/cascadia 4f03c71bc42b
.google.com/p/go-uuid 7dda39b2e7d5

[1] “repo root” refers to the base package in a repository. For example, although code.google.com/p/go.net/websocket is a Go package, code.google.com/p/go.net is the “repo root”, and any dependencies on non-root packages roll up to the root.

Use case

It is meant to serve a team that:

For example, at work we keep our Go code in one repo (rather than many small ones) and use a single GOPATH. This tool allows us to gain reproducible builds, with version updates automatically propagated to the team via the hook, with the following advantages:

Setup

Here is how to get started with Glock.

tch and install glock
 get github.com/robfig/glock

cord the package's transitive dependencies, as they currently exist.
ock writes the dependencies to a GLOCKFILE in that package's directory.
l dependencies of all descendent packages are included.
ock save github.com/acme/project

view and check in the dependencies.
t add src/github.com/acme/project/GLOCKFILE
t commit -m 'Save current dependency revisions'
t push

l developers install the git hook
ock install github.com/acme/project

Once the VCS hook is installed, all developers will have their dependencies added and updated automatically as the GLOCKFILE changes.

Add/update a dependency
veloper wants to add a dependency
 get -u github.com/some/dependency
ock save github.com/acme/project
t commit src/github.com/acme/project/GLOCKFILE
t push

“go get -u” will download the latest revision of that library and update to it. “glock save” records the current state of dependencies in your GOPATH, which should reflect the new or updated revision.

You can use the same process to update all dependencies to the latest revision:

 $GOPATH/src
 get -u -v ./...
ock save github.com/acme/project

In any case, the dependency update will be propagated to all team members as they pull that revision.

Continuous Integration

It may also be useful to verify that all dependencies are recorded as part of your continuous build. A simple diff works:

ff <(glock save -n github.com/acme/project) <(cat github.com/acme/project/GLOCKFILE)

That will return success (0) if there were no differences between the current project dependencies and what is recorded in the GLOCKFILE, or it will exit with an error (1) and print the differences.

Commands

Glock can also be used to build and update go programs across the team.

Commands are declared at the top of your GLOCKFILE:

code.google.com/p/go.tools/cmd/godoc
code.google.com/p/go.tools/cmd/goimports
code.google.com/p/go.tools/cmd/vet

The declarations have a couple effects:


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.