You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ritesh Chitlangi c417114111 path replacement for groups 2 months ago
scm path replacement for groups 2 months ago
.drone.yml updated module path 2 months ago
.gitignore improve bitbucket unauthorized error 4 years ago
BUILDING initial commit 5 years ago
CHANGELOG.md updated module path 2 months ago
COPYRIGHT initial commit 5 years ago
LICENSE endpoint to get github organization membership role 3 years ago
README.md updated module path 2 months ago
go.mod updated module path 2 months ago
go.sum updated module path 2 months ago

README.md

Go Doc

Package scm provides a unified interface to multiple source code management systems including GitHub, GitHub Enterprise, Bitbucket, Bitbucket Server, Gitea and Gogs.

Getting Started

Create a GitHub client:

package main

import (
	"git.finology.group/ritesh/go-scm/scm"
	"git.finology.group/ritesh/go-scm/scm/driver/github"
)

func main() {
	client := github.NewDefault()
}

Create a GitHub Enterprise client:

import (
	"git.finology.group/ritesh/go-scm/scm"
	"git.finology.group/ritesh/go-scm/scm/driver/github"
)

func main() {
    client, err := github.New("https://github.company.com/api/v3")
}

Create a Bitbucket client:

import (
	"git.finology.group/ritesh/go-scm/scm"
	"git.finology.group/ritesh/go-scm/scm/driver/bitbucket"
)

func main() {
    client, err := bitbucket.New()
}

Create a Bitbucket Server (Stash) client:

import (
	"git.finology.group/ritesh/go-scm/scm"
	"git.finology.group/ritesh/go-scm/scm/driver/stash"
)

func main() {
    client, err := stash.New("https://stash.company.com")
}

Create a Gitea client:

import (
	"git.finology.group/ritesh/go-scm/scm"
	"git.finology.group/ritesh/go-scm/scm/driver/github"
)

func main() {
    client, err := gitea.New("https://gitea.company.com")
}

Authentication

The scm client does not directly handle authentication. Instead, when creating a new client, provide a http.Client that can handle authentication for you. For convenience, this library includes oauth1 and oauth2 implementations that can be used to authenticate requests.

package main

import (
	"git.finology.group/ritesh/go-scm/scm"
	"git.finology.group/ritesh/go-scm/scm/driver/github"
	"git.finology.group/ritesh/go-scm/scm/driver/transport/oauth2"
)

func main() {
	client := github.NewDefault()

	// provide a custom http.Client with a transport
	// that injects the oauth2 token.
	client.Client := &http.Client{
		Transport: &Transport{
			Source: StaticTokenSource(
				&scm.Token{
					Token: "ecf4c1f9869f59758e679ab54b4",
				},
			),
		},
	}

	// provide a custom http.Client with a transport
	// that injects the private GitLab token through
	// the PRIVATE_TOKEN header variable.
	client.Client := &http.Client{
		Transport: &PrivateToken{
			Token: "ecf4c1f9869f59758e679ab54b4",
		},
	}
}