GithubHelp home page GithubHelp logo

stash's Introduction

Stash tools

Go package of Stash tools.

This library uses glide for dependency management.

Installation

make

Usage

go get github.com/xoom/stash

import "github.com/xoom/stash"

Stash Rest API Documentation

NewClient

stashClient := stash.NewClient("stash_user", "stash_pwd", "http://stash-url.local:7990")

Inject http client

httpTransport := &http.Transport{
		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
	}

httpClient := &http.Client{Timeout: 20 * time.Second, Transport: httpTransport}

stashClient := stash.NewClient("stash_user", "stash_pwd", "http://stash-url.local:7990")

stashClient.SetHTTPClient(httpClient)

CreateRepository

repository, err := stashClient.CreateRepository("PROJ", "slug")

GetRepositories

repository, err := stashClient.GetRepository("PROJ", "slug")

GetBranches

branches, err := stashClient.GetBranches("PROJ", "slug")

GetRepository

repository, err := stashClient.GetRepository("PROJ", "slug")

CreateBranchRestriction

branchRestriction, err := stashClient.CreateBranchRestriction("PROJ", "slug", "develop", "user")

GetBranchRestrictions

branchRestrictions, err := stashClient.GetBranchRestrictions("PROJ", "slug")

DeleteBranchRestriction

err := stashClient.DeleteBranchRestriction("PROJ", "slug", branchRestriction.Id)

ApprovePullRequest

err := stashClient.ApprovePullRequest("PROJ", "slug", pullRequest.Id, 0)

MergePullRequest

err := stashClient.MergePullRequest("PROJ", "slug", pullRequest.Id, 0)

GetPullRequests

// get all pull requests
pullRequests, err := stashClient.GetPullRequests("PROJ", "slug", "")

// get pull request by state
state := "OPEN"
pullRequests, err := stashClient.GetPullRequests("PROJ", "slug", state)

GetPullRequest

// get pull request by id
pullRequest, err := stashClient.GetPullRequest("PROJ", "slug", 1)

CreatePullRequest

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)

CreateComment

comment, err := stashClient.CreateComment("PROJ", "slug", 1, "build passing")

UpdatePullRequest

title     := "New title"
desc      := "New description"
branch    := "master"

pullRequest, err := stashClient.UpdatePullRequest("PROJ", "slug", "1", 10, title, desc, branch, nil)

GetRawFile

filePath := "foo/bar"
branch   := "develop"

data, _ := stashClient.GetRawFile("PRJ", "slug", filePath, branch)

fmt.Println(string(data))

stash

Development

Local stash instance

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

stash's People

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.