stash

package module
v0.0.0-...-5ddab3c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2015 License: MIT Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Stash tools

Go package of Stash tools

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")
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)
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)
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)
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

Documentation

Overview

Atlassian Stash API package. Stash API Reference: https://developer.atlassian.com/static/rest/stash/3.0.1/stash-rest.html

Index

Constants

This section is empty.

Variables

Functions

func IsRepositoryExists

func IsRepositoryExists(err error) bool

func IsRepositoryNotFound

func IsRepositoryNotFound(err error) bool

Types

type Branch

type Branch struct {
	ID              string `json:"id"`
	DisplayID       string `json:"displayId"`
	LatestChangeSet string `json:"latestChangeset"`
	IsDefault       bool   `json:"isDefault"`
}

type BranchPermission

type BranchPermission struct {
	Type   string   `json:"type"`
	Branch string   `json:"value"`
	Users  []string `json:"users"`
	Groups []string `json:"groups"`
}

type BranchRestriction

type BranchRestriction struct {
	Id     int    `json:"id"`
	Branch Branch `json:"branch"`
}

type BranchRestrictions

type BranchRestrictions struct {
	BranchRestriction []BranchRestriction `json:"values"`
}

type Branches

type Branches struct {
	IsLastPage    bool     `json:"isLastPage"`
	Size          int      `json:"size"`
	Start         int      `json:"start"`
	NextPageStart int      `json:"nextPageStart"`
	Branch        []Branch `json:"values"`
}

type Client

type Client struct {
	Stash
	// contains filtered or unexported fields
}

func (Client) CreateBranchRestriction

func (client Client) CreateBranchRestriction(projectKey, repositorySlug, branch, user string) (BranchRestriction, error)

func (Client) CreatePullRequest

func (client Client) CreatePullRequest(projectKey, repositorySlug, title, description, fromRef, toRef string, reviewers []string) (PullRequest, error)

CreatePullRequest creates a pull request between branches.

func (Client) CreateRepository

func (client Client) CreateRepository(projectKey, projectSlug string) (Repository, error)

func (Client) DeleteBranch

func (client Client) DeleteBranch(projectKey, repositorySlug, branchName string) error

func (Client) DeleteBranchRestriction

func (client Client) DeleteBranchRestriction(projectKey, repositorySlug string, id int) error

GetRepository returns a repository representation for the given Stash Project key and repository slug.

func (Client) GetBranchRestrictions

func (client Client) GetBranchRestrictions(projectKey, repositorySlug string) (BranchRestrictions, error)

func (Client) GetBranches

func (client Client) GetBranches(projectKey, repositorySlug string) (map[string]Branch, error)

GetBranches returns a map of branches indexed by branch display name for the given repository.

func (Client) GetPullRequests

func (client Client) GetPullRequests(projectKey, projectSlug, state string) ([]PullRequest, error)

GetPullRequests returns a list of pull requests for a project / slug.

func (Client) GetRawFile

func (client Client) GetRawFile(repositoryProjectKey, repositorySlug, filePath, branch string) ([]byte, error)

func (Client) GetRepositories

func (client Client) GetRepositories() (map[int]Repository, error)

GetRepositories returns a map of repositories indexed by repository URL.

func (Client) GetRepository

func (client Client) GetRepository(projectKey, repositorySlug string) (Repository, error)

GetRepository returns a repository representation for the given Stash Project key and repository slug.

func (Client) GetTags

func (client Client) GetTags(projectKey, repositorySlug string) (map[string]Tag, error)

GetTags returns a map of tags indexed by tag display name for the given repository.

type Clone

type Clone struct {
	HREF string `json:"href"`
	Name string `json:"name"`
}
type Links struct {
	Clones []Clone `json:"clone"`
}

type Page

type Page struct {
	IsLastPage    bool `json:"isLastPage"`
	Size          int  `json:"size"`
	Start         int  `json:"start"`
	NextPageStart int  `json:"nextPageStart"`
}

type Project

type Project struct {
	Key string `json:"key"`
}

type PullRequest

type PullRequest struct {
	ID          int    `id:"closed"`
	Closed      bool   `json:"closed"`
	Open        bool   `json:"open"`
	State       string `json:"state"`
	Title       string `json:"title"`
	Description string `json:"description"`
	FromRef     Ref    `json:"fromRef"`
	ToRef       Ref    `json:"toRef"`
}

type PullRequestProject

type PullRequestProject struct {
	Key string `json:"key"`
}

type PullRequestRef

type PullRequestRef struct {
	Id         string                `json:"id"`
	Repository PullRequestRepository `json:"repository"`
}

type PullRequestRepository

type PullRequestRepository struct {
	Slug    string             `json:"slug"`
	Name    string             `json:"name,omitempty"`
	Project PullRequestProject `json:"project"`
}

type PullRequestResource

type PullRequestResource struct {
	Title       string         `json:"title"`
	Description string         `json:"description"`
	FromRef     PullRequestRef `json:"fromRef"`
	ToRef       PullRequestRef `json:"toRef"`
	Reviewers   []Reviewer     `json:"reviewers"`
}

type PullRequests

type PullRequests struct {
	Page
	PullRequests []PullRequest `json:"values"`
}

type Ref

type Ref struct {
	DisplayID string `json:"displayId"`
}

type Repositories

type Repositories struct {
	IsLastPage    bool         `json:"isLastPage"`
	Size          int          `json:"size"`
	Start         int          `json:"start"`
	NextPageStart int          `json:"nextPageStart"`
	Repository    []Repository `json:"values"`
}

type Repository

type Repository struct {
	ID      int     `json:"id"`
	Name    string  `json:"name"`
	Slug    string  `json:"slug"`
	Project Project `json:"project"`
	ScmID   string  `json:"scmId"`
	Links   Links   `json:"links"`
}

func HasRepository

func HasRepository(repositories map[int]Repository, url string) (Repository, bool)

func (Repository) SshUrl

func (repo Repository) SshUrl() string

SshUrl extracts the SSH-based URL from the repository metadata.

type Reviewer

type Reviewer struct {
	User User `json:"user"`
}

type Stash

type Stash interface {
	CreateRepository(projectKey, slug string) (Repository, error)
	GetRepositories() (map[int]Repository, error)
	GetBranches(projectKey, repositorySlug string) (map[string]Branch, error)
	GetTags(projectKey, repositorySlug string) (map[string]Tag, error)
	CreateBranchRestriction(projectKey, repositorySlug, branch, user string) (BranchRestriction, error)
	GetBranchRestrictions(projectKey, repositorySlug string) (BranchRestrictions, error)
	DeleteBranchRestriction(projectKey, repositorySlug string, id int) error
	GetRepository(projectKey, repositorySlug string) (Repository, error)
	GetPullRequests(projectKey, repositorySlug, state string) ([]PullRequest, error)
	GetRawFile(projectKey, repositorySlug, branch, filePath string) ([]byte, error)
	CreatePullRequest(projectKey, repositorySlug, title, description, fromRef, toRef string, reviewers []string) (PullRequest, error)
	DeleteBranch(projectKey, repositorySlug, branchName string) error
}

func NewClient

func NewClient(userName, password string, baseURL *url.URL) Stash

type Tag

type Tag struct {
	ID        string `json:"id"`
	DisplayID string `json:"displayId"`
}

type Tags

type Tags struct {
	Page
	Tags []Tag `json:"values"`
}

type User

type User struct {
	Name string `json:"name"`
}

Directories

Path Synopsis
Godeps

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL