Skip to content

Package scm provides a unified interface to multiple source code management systems.

License

Notifications You must be signed in to change notification settings

frazergibsonntt/go-scm

This branch is 6 commits ahead of, 306 commits behind jenkins-x/go-scm:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

326669c · May 21, 2021
Mar 10, 2021
Apr 29, 2021
Apr 15, 2021
Oct 12, 2020
May 21, 2021
Feb 6, 2021
Dec 21, 2020
Jul 31, 2019
Jun 6, 2019
Dec 13, 2017
Dec 13, 2017
Oct 12, 2020
May 14, 2020
Mar 22, 2021
Apr 29, 2021
Apr 1, 2021
Apr 1, 2021
Oct 12, 2020
Jul 20, 2020

Repository files navigation

go-scm

Documentation Go Report Card

A small library with minimal depenencies for working with Webhooks, Commits, Issues, Pull Requests, Comments, Reviews, Teams and more on multiple git provider:

Building

See the guide to prerequisites, building and running the code

Working on the code

Clone this repository and use go test...

git clone https://github.com/jenkins-x/go-scm.git
cd go-scm
go test ./...

Writing tests

There are lots of tests for each driver; using sample JSON that comes from the git provider together with the expected canonical JSON.

e.g. I added this test for ListTeams on github: https://github.com/jenkins-x/go-scm/blob/master/scm/driver/github/org_test.go#L83-116

you then add some real json from the git provider: https://github.com/jenkins-x/go-scm/blob/master/scm/driver/github/testdata/teams.json and provide the expected json: https://github.com/jenkins-x/go-scm/blob/master/scm/driver/github/testdata/teams.json.golden

Trying the client on a provider

There are a few little sample programs in scm/factory/examples which are individual binaries you can run from the command line or your IDE.

To test against a git provider of your choice try defining these environment variables:

  • GIT_KIND for the kind of git provider (e.g. github, bitbucketserver, gitlab etc)
  • GIT_SERVER for the URL of the server to communicate with
  • GIT_USER for git user name if using bitbucketclient
  • GIT_TOKEN for the git OAuth/private token to talk to the git server

Git API Reference docs

To help hack on the different drivers here's a list of docs which outline the git providers REST APIs

GitHub

Bitbucket Server

Bitbucket Cloud

Gitlab

Fake driver for testing

When testing the use of go-scm its really handy to use the fake provider which lets you populate the in memory resources inside the driver or query resources after a test has run.

client, data := fake.NewDefault()

Community

We have a kanban board of stuff to work on if you fancy contributing!

You can also find us on Slack at kubernetes.slack.com:

About

Package scm provides a unified interface to multiple source code management systems.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.8%
  • Other 0.2%