Giter Club home page Giter Club logo

gpm-git's Introduction

gpm-git: Local Git Package Management for Go

gpm is a tool for managing Go packages. gpm-git is a plugin that adds support for direct Git management of directories inside of a gpm-managed $GOPATH.

Use Cases

Using this plugin, you can use GPM to...

  • Work with Git repos that are password protected (e.g. private Bitbucket repos).
  • Use any git repo that git clone can use.
  • Clone a full git repo into a local working copy, and modify it within the copy. (Not necessarily recommended, but possible).

Installation

Put gpm-git in your $PATH. You can do this easily by running make install.

TODO:

  • Add homebrew support.
  • Test on Linux.
  • Add testing target.

Usage

gpm-git uses a special file called Gopath-Git to read the repos that it needs. This file differs slightly from the regular GPM Gopath file. It uses up to three fields separated by whitespace:

GIT_URL   GO_PKG_NAME   [VERSION]
  • GIT_URL: The URL to the git repository.
  • GO_PKG_NAME: The full name of the package in Go's package name format.
  • VERSION: The git commit or reference.

Here's an example file:


# Get the tip of master of the foo/bar project
[email protected]:foo/bar bitbucket.org/foo/bar master
# This works, too
# [email protected]:foo/bar bitbucket.org/foo/bar

# Get a specific commit or tag off of foo/baz
[email protected]:foo/baz bitbucket.org/foo/baz 2feb1ef
[email protected]:foo/argh bitbucket.org/foo/argh 1.2.3

Once you have a Gopath-Git file, you can use gpm-git like this:

$ gpm git

The above will attempt to clone (or fetch --all if the clone exists) the given URL, and then place it in the appropriate location in .godeps.

Once you have a repo initialized, you can manage it directly by going into .godeps/src, or you can simply update the package by calling gpm git again.

Under the Hood

If you're interested in knowing how gpm-git works, here's the high-level overview:

  1. It reads the Gopath-Git file line by line, breaking it into fields.
  2. For each GIT_URL it creates a new package path in .godeps/src and then clones the git repository into it. It uses whichever version of git it finds on the $PATH.
  3. If a VERSION is set, it checks out that particular version.

For performance reasons, re-running gpm git will not re-clone each repository. Instead it will git fetch --all. I did this because large git repos can take a really long time to download.

See Also

gpm-git's People

Contributors

technosophos avatar babo avatar

Stargazers

 avatar Suriyaa Sundararuban avatar Denis Ryabokon avatar Hannes Voigt-Georg avatar Vasudev Kamath avatar pote avatar

Watchers

 avatar James Cloos avatar  avatar

gpm-git's Issues

Breaks gpm-prebuild and other tools when Go package is a subdirectory of the repository

For example, if I want to use gpm-git to pull in the awesome dotcloud/docker/pkg/namesgenerator library, I have two options. I can write my Godeps-git file like:

https://github.com/dotcloud/docker.git github.com/dotcloud/docker/pkg/namesgenerator c9f216d

in which case gpm-prebuild works correctly because it only tries to compile the namesgenerator, but my Go package fails because the entire repository was cloned at $GOPATH/src/github.com/dotcloud/docker/pkg/namesgenerator. My other option is to write my Godeps-Git file like:

https://github.com/dotcloud/docker.git github.com/dotcloud/docker c9f216d

in which case my Go package works but tools like gpm-prebuild do not because I don't have all the dependencies for Docker.

I think gpm-git should be able to accept the first way and figure out the right location for cloning the repository.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.