Go package of Stash tools.
This library uses glide for dependency management.
make
go get github.com/xoom/stash
import "github.com/xoom/stash"
stashClient := stash.NewClient("stash_user", "stash_pwd", "http://stash-url.local:7990")
repository, err := stashClient.CreateRepository("PROJ", "slug")
repository, err := stashClient.GetRepository("PROJ", "slug")
branches, err := stashClient.GetBranches("PROJ", "slug")
repository, err := stashClient.GetRepository("PROJ", "slug")
branchRestriction, err := stashClient.CreateBranchRestriction("PROJ", "slug", "develop", "user")
branchRestrictions, err := stashClient.GetBranchRestrictions("PROJ", "slug")
err := stashClient.DeleteBranchRestriction("PROJ", "slug", branchRestriction.Id)
err := stashClient.ApprovePullRequest("PROJ", "slug", pullRequest.Id, 0)
err := stashClient.MergePullRequest("PROJ", "slug", pullRequest.Id, 0)
// get all pull requests
pullRequests, err := stashClient.GetPullRequests("PROJ", "slug", "")
// get pull request by state
state := "OPEN"
pullRequests, err := stashClient.GetPullRequests("PROJ", "slug", state)
// get pull request by id
pullRequest, err := stashClient.GetPullRequest("PROJ", "slug", 1)
title := "A Title"
des := "A Description"
from := "feature/file1"
to := "develop"
reviewers := []string{"bob", "bill"}
pullRequest, err := stashClient.CreatePullRequest("PROJ", "slug", title, desc, from, to, reviewers)
comment, err := stashClient.CreateComment("PROJ", "slug", 1, "build passing")
title := "New title"
desc := "New description"
branch := "master"
pullRequest, err := stashClient.UpdatePullRequest("PROJ", "slug", "1", 10, title, desc, branch, nil)
filePath := "foo/bar"
branch := "develop"
data, _ := stashClient.GetRawFile("PRJ", "slug", filePath, branch)
fmt.Println(string(data))
Download and run a development instance of stash via a docker image.
# pick a directory where to save the data generated by the container
export STASH_DATA="${HOME}/stash/data"
# for a linux host
$ docker run -u root -v $STASH_DATA:/var/atlassian/application-data/stash atlassian/stash chown -R daemon /var/atlassian/application-data/stash
$ docker run -v $STASH_DATA:/var/atlassian/application-data/stash --name="stash" -d -p 7990:7990 -p 7999:7999 atlassian/stash
# for a MacOs Host via 'boot2docker'
$ docker run -u root -v $STASH_DATA:/var/atlassian/application-data/stash --name=stash -d -p 7990:7990 -p 7999:7999 atlassian/stash
Open your browser to http://localhost:7990
and follow the setup instructions.
** If your are using boot2docker get your IP via boot2docker ip