{"id":13786693,"url":"https://github.com/jfrog/froggit-go","last_synced_at":"2025-09-27T22:31:46.367Z","repository":{"id":39882991,"uuid":"401631453","full_name":"jfrog/froggit-go","owner":"jfrog","description":"Froggit-Go is a universal Go library, allowing to perform actions on VCS providers.","archived":false,"fork":false,"pushed_at":"2024-10-13T09:44:49.000Z","size":727,"stargazers_count":45,"open_issues_count":12,"forks_count":17,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-22T11:56:45.366Z","etag":null,"topics":["awesome","awesome-go","bitbucket","bitbucket-cloud","bitbucket-server","git","github","github-enterprise","gitlab","go","go-library","golang","vcs-client","vcs-tools","webhook"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/jfrog/froggit-go","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jfrog.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-31T08:38:39.000Z","updated_at":"2024-10-13T08:03:11.000Z","dependencies_parsed_at":"2022-07-15T07:31:08.541Z","dependency_job_id":"6c0dd015-72a8-4bc6-a1a5-6c449bf3de61","html_url":"https://github.com/jfrog/froggit-go","commit_stats":null,"previous_names":[],"tags_count":48,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfrog%2Ffroggit-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfrog%2Ffroggit-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfrog%2Ffroggit-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfrog%2Ffroggit-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jfrog","download_url":"https://codeload.github.com/jfrog/froggit-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234462106,"owners_count":18837263,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["awesome","awesome-go","bitbucket","bitbucket-cloud","bitbucket-server","git","github","github-enterprise","gitlab","go","go-library","golang","vcs-client","vcs-tools","webhook"],"created_at":"2024-08-03T19:01:28.741Z","updated_at":"2025-09-27T22:31:46.361Z","avatar_url":"https://github.com/jfrog.png","language":"Go","funding_links":[],"categories":["Version Control","版本控制","Utility"],"sub_categories":["Utility/Miscellaneous","实用程序/Miscellaneous","Fail injection"],"readme":"\u003cdiv align=\"center\"\u003e\n\n# Froggit-Go\n\n[![Frogbot](images/header.png)](#readme)\n\n\u003c/div\u003e\n\nFroggit-Go is a Go library, allowing to perform actions on VCS providers.\nCurrently supported providers are: [GitHub](#github), [Bitbucket Server](#bitbucket-server)\n, [Bitbucket Cloud](#bitbucket-cloud), [Azure Repos](#azure-repos) and [GitLab](#gitlab).\n\n## Project status\n\n[![Scanned by Frogbot](https://raw.github.com/jfrog/frogbot/master/images/frogbot-badge.svg)](https://github.com/jfrog/frogbot#readme)\n[![Test](https://github.com/jfrog/froggit-go/actions/workflows/test.yml/badge.svg)](https://github.com/jfrog/froggit-go/actions/workflows/test.yml)\n[![Coverage Status](https://coveralls.io/repos/github/jfrog/froggit-go/badge.svg?branch=master)](https://coveralls.io/github/jfrog/froggit-go?branch=master)\n[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)\n[![Go Report Card](https://goreportcard.com/badge/github.com/jfrog/froggit-go)](https://goreportcard.com/report/github.com/jfrog/froggit-go)\n\n## Usage\n\n- [Froggit-Go](#froggit-go)\n  - [Project status](#project-status)\n  - [Usage](#usage)\n    - [VCS Clients](#vcs-clients)\n      - [Create Clients](#create-clients)\n        - [GitHub](#github)\n        - [GitLab](#gitlab)\n        - [Bitbucket Server](#bitbucket-server)\n        - [Bitbucket Cloud](#bitbucket-cloud)\n        - [Azure Repos](#azure-repos)\n      - [Test Connection](#test-connection)\n      - [List Repositories](#list-repositories)\n      - [List App Repositories](#list-app-repositories)\n      - [List Branches](#list-branches)\n      - [List Pull Request Reviews](#list-pull-request-reviews)\n      - [Download Repository](#download-repository)\n      - [Create Webhook](#create-webhook)\n      - [Update Webhook](#update-webhook)\n      - [Delete Webhook](#delete-webhook)\n      - [Set Commit Status](#set-commit-status)\n      - [Get Commit Status](#get-commit-status)\n      - [Create Pull Request](#create-pull-request)\n      - [Update Pull Request](#update-pull-request)\n      - [Get Pull Request By ID](#get-pull-request-by-id)\n      - [List Open Pull Requests](#list-open-pull-requests)\n      - [List Open Pull Requests With Body](#list-open-pull-requests-with-body)\n      - [Add Pull Request Comment](#add-pull-request-comment)\n      - [Add Pull Request Review Comments](#add-pull-request-review-comments)\n      - [List Pull Request Comments](#list-pull-request-comments)\n      - [List Pull Request Review Comments](#list-pull-request-review-comments)\n      - [Delete Pull Request Comment](#delete-pull-request-comment)\n      - [Delete Pull Request Review Comments](#delete-pull-request-review-comments)\n      - [Get Commits](#get-commits)\n      - [Get Commits With Options](#get-commits-with-options)\n      - [Get Latest Commit](#get-latest-commit)\n      - [Get Commit By SHA](#get-commit-by-sha)\n      - [List Pull Requests associated with a Commit](#list-pull-requests-associated-with-a-commit)\n      - [Get List of Modified Files](#get-list-of-modified-files)\n      - [Add Public SSH Key](#add-public-ssh-key)\n      - [Get Repository Info](#get-repository-info)\n      - [Get Repository Environment Info](#get-repository-environment-info)\n      - [Create a label](#create-a-label)\n      - [Get a label](#get-a-label)\n      - [List Pull Request Labels](#list-pull-request-labels)\n      - [Unlabel Pull Request](#unlabel-pull-request)\n      - [Upload Code Scanning](#upload-code-scanning)\n      - [Download a File From a Repository](#download-a-file-from-a-repository)\n      - [Create a branch](#create-branch)\n      - [Allow workflows on organization](#allow-workflows)\n      - [Add Organization Secret](#add-organization-secret)\n      - [Get Repo Collaborators](#get-repo-collaborators)\n      - [Get Repo Teams By Permissions](#get-repo-teams-by-permissions)\n      - [Create Or Update Environment](#create-or-update-environment)\n      - [CommitAndPushFiles](#commit-and-push-files)\n      - [Merge Pull Request](#merge-pull-request)\n      - [Create Pull Request Detailed](#create-pull-request-detailed)\n      - [Upload Snapshot To Dependency Graph](#upload-snapshot-to-dependency-graph)\n    - [Webhook Parser](#webhook-parser)\n\n### VCS Clients\n\n#### Create Clients\n\n##### GitHub\n\nGitHub api v3 is used\n\n```go\n// The VCS provider. Cannot be changed.\nvcsProvider := vcsutils.GitHub\n// API endpoint to GitHub. Leave empty to use the default - https://api.github.com\napiEndpoint := \"https://github.example.com\"\n// Access token to GitHub\ntoken := \"secret-github-token\"\n// Logger\n// [Optional]\n// Supported logger is a logger that implements the Log interface.\n// More information - https://github.com/jfrog/froggit-go/blob/master/vcsclient/logger.go\nlogger := log.Default()\n\nclient, err := vcsclient.NewClientBuilder(vcsProvider).ApiEndpoint(apiEndpoint).Token(token).Build()\n```\n\n##### GitLab\n\nGitLab api v4 is used.\n\n```go\n// The VCS provider. Cannot be changed.\nvcsProvider := vcsutils.GitLab\n// API endpoint to GitLab. Leave empty to use the default - https://gitlab.com\napiEndpoint := \"https://gitlab.example.com\"\n// Access token to GitLab\ntoken := \"secret-gitlab-token\"\n// Logger\n// [Optional]\n// Supported logger is a logger that implements the Log interface.\n// More information - https://github.com/jfrog/froggit-go/blob/master/vcsclient/logger.go\nlogger := logger\n\nclient, err := vcsclient.NewClientBuilder(vcsProvider).ApiEndpoint(apiEndpoint).Token(token).Build()\n```\n\n##### Bitbucket Server\n\nBitbucket api 1.0 is used.\n\n```go\n// The VCS provider. Cannot be changed.\nvcsProvider := vcsclient.BitbucketServer\n// API endpoint to Bitbucket server. Typically ends with /rest.\napiEndpoint := \"https://git.acme.com/rest\"\n// Access token to Bitbucket\ntoken := \"secret-bitbucket-token\"\n// Logger\n// [Optional]\n// Supported logger is a logger that implements the Log interface.\n// More information - https://github.com/jfrog/froggit-go/blob/master/vcsclient/logger.go\nlogger := log.Default()\n\nclient, err := vcsclient.NewClientBuilder(vcsProvider).ApiEndpoint(apiEndpoint).Token(token).Build()\n```\n\n##### Bitbucket Cloud\n\nBitbucket cloud api version 2.0 is used and the version should be added to the apiEndpoint.\n\n```go\n// The VCS provider. Cannot be changed.\nvcsProvider := vcsutils.BitbucketCloud\n// API endpoint to Bitbucket cloud. Leave empty to use the default - https://api.bitbucket.org/2.0\napiEndpoint := \"https://bitbucket.example.com\"\n// Bitbucket username\nusername := \"bitbucket-user\"\n// Password or Bitbucket \"App Password'\ntoken := \"secret-bitbucket-token\"\n// Logger\n// [Optional]\n// Supported logger is a logger that implements the Log interface.\n// More information - https://github.com/jfrog/froggit-go/blob/master/vcsclient/logger.go\nlogger := log.Default()\n\nclient, err := vcsclient.NewClientBuilder(vcsProvider).ApiEndpoint(apiEndpoint).Username(username).Token(token).Build()\n```\n\n##### Azure Repos\n\nAzure DevOps api version v6 is used.\n\n```go\n// The VCS provider. Cannot be changed.\nvcsProvider := vcsutils.AzureRepos\n// API endpoint to Azure Repos. Set the organization.\napiEndpoint := \"https://dev.azure.com/\u003corganization\u003e\"\n// Personal Access Token to Azure DevOps\ntoken := \"secret-azure-devops-token\"\n// Logger\n// [Optional]\n// Supported logger is a logger that implements the Log interface.\n// More information - https://github.com/jfrog/froggit-go/blob/master/vcsclient/logger.go\nlogger := log.Default()\n// Project name\nproject := \"name-of-the-relevant-project\"\n\nclient, err := vcsclient.NewClientBuilder(vcsProvider).ApiEndpoint(apiEndpoint).Token(token).Project(project).Build()\n```\n\n#### Test Connection\n\n```go\n// Go context\nctx := context.Background()\n\nerr := client.TestConnection(ctx)\n```\n\n#### List Repositories\n\n```go\n// Go context\nctx := context.Background()\n\nrepositories, err := client.ListRepositories(ctx)\n```\n\n#### List App Repositories\n\nReturns a map between all accessible Apps and their list of repositories.  \nNote: Currently supported for GitHub Apps only.\n\n```go\n// Go context\nctx := context.Background()\n\n// List all repositories accessible by the app (for example, a GitHub App installation)\nappRepositories, err := client.ListAppRepositories(ctx)\nif err != nil {\n    // handle error\n}\nfor owner, repos := range appRepositories {\n    fmt.Printf(\"Owner: %s\\n\", owner)\n    for _, repo := range repos {\n        fmt.Printf(\"  - %s\\n\", repo)\n    }\n}\n```\n\n#### List Branches\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n\nrepositoryBranches, err := client.ListBranches(ctx, owner, repository)\n```\n\n#### List Pull Request Reviews\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// Pull Request ID\npullRequestID := 1\n\n// List all reviews for pull request 1\nreviews, err := client.ListPullRequestReviews(ctx, owner, repository, pullRequestID)\n```\n\n#### Download Repository\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// Repository branch\nbranch := \"master\"\n// Local path in the file system\nlocalPath := \"/Users/frogger/code/jfrog-cli\"\n\nrepositoryBranches, err := client.DownloadRepository(ctx, owner, repository, branch, localPath)\n```\n\n#### Create Webhook\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// The event to watch\nwebhookEvent := vcsutils.Push\n// VCS repository\nrepository := \"jfrog-cli\"\n// Optional - Webhooks on branches are supported only on GitLab\nbranch := \"\"\n// The URL to send the payload upon a webhook event\npayloadURL := \"https://acme.jfrog.io/integration/api/v1/webhook/event\"\n\n// token - A token used to validate identity of the incoming webhook.\n// In GitHub and Bitbucket server the token verifies the sha256 signature of the payload.\n// In GitLab and Bitbucket cloud the token compared to the token received in the incoming payload.\nid, token, err := client.CreateWebhook(ctx, owner, repository, branch, \"https://jfrog.com\", webhookEvent)\n```\n\n#### Update Webhook\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// Optional - Webhooks on branches are supported only on GitLab\nbranch := \"\"\n// The URL to send the payload upon a webhook event\npayloadURL := \"https://acme.jfrog.io/integration/api/v1/webhook/event\"\n// A token to validate identity of the webhook, created by CreateWebhook command\ntoken := \"abc123\"\n// The webhook ID returned by the CreateWebhook API, which created this webhook\nwebhookID := \"123\"\n// The event to watch\nwebhookEvent := vcsutils.PrCreated\n\nerr := client.UpdateWebhook(ctx, owner, repository, branch, \"https://jfrog.com\", token, webhookID, webhookEvent)\n```\n\n#### Delete Webhook\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// The webhook ID returned by the CreateWebhook API, which created this webhook\nwebhookID := \"123\"\n\nerr := client.DeleteWebhook(ctx, owner, repository, webhookID)\n```\n\n#### Set Commit Status\n\n```go\n// Go context\nctx := context.Background()\n// One of Pass, Fail, Error, or InProgress\ncommitStatus := vcsclient.Pass\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// Branch or commit or tag on GitHub and GitLab, commit on Bitbucket\nref := \"5c05522fecf8d93a11752ff255c99fcb0f0557cd\"\n// Title of the commit status\ntitle := \"Xray scanning\"\n// Description of the commit status\ndescription := \"Run JFrog Xray scan\"\n// URL leads to the platform to provide more information, such as Xray scanning results\ndetailsURL := \"https://acme.jfrog.io/ui/xray-scan-results-url\"\n\nerr := client.SetCommitStatus(ctx, commitStatus, owner, repository, ref, title, description, detailsURL)\n```\n\n#### Get Commit Status\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// Commit tag on GitHub and GitLab, commit on Bitbucket\nref := \"5c05522fecf8d93a11752ff255c99fcb0f0557cd\"\n\ncommitStatuses, err := client.GetCommitStatus(ctx, owner, repository, ref)\n```\n\n##### Create Pull Request\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// Source pull request branch\nsourceBranch := \"dev\"\n// Target pull request branch\ntargetBranch := \"main\"\n// Pull request title\ntitle := \"Pull request title\"\n// Pull request description\ndescription := \"Pull request description\"\n\nerr := client.CreatePullRequest(ctx, owner, repository, sourceBranch, targetBranch, title, description)\n```\n\n##### Update Pull Request\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// Target pull request branch, leave empty for no change.\ntargetBranch := \"main\"\n// Pull request title\ntitle := \"Pull request title\"\n// Pull request description\nbody := \"Pull request description\"\n// Pull request ID\nid := \"1\"\n// Pull request state\nstate := vcsutils.Open\n\nerr := client.UpdatePullRequest(ctx, owner, repository, title, body, targetBranch, id, state)\n```\n\n#### List Open Pull Requests With Body\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n\nopenPullRequests, err := client.ListOpenPullRequestsWithBody(ctx, owner, repository)\n```\n\n#### List Open Pull Requests\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n\nopenPullRequests, err := client.ListOpenPullRequests(ctx, owner, repository)\n```\n\n#### Get Pull Request By ID\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// Pull Request ID\npullRequestId := 1\n\nopenPullRequests, err := client.GetPullRequestByID(ctx, owner, repository, pullRequestId)\n```\n\n##### Add Pull Request Comment\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// Comment content\ncontent := \"Comment content\"\n// Pull Request ID\npullRequestID := 5\n\nerr := client.AddPullRequestComment(ctx, owner, repository, content, pullRequestID)\n```\n\n##### Add Pull Request Review Comments\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// Pull Request ID\npullRequestID := 5\n// Pull Request Comment\ncomments := []PullRequestComment{\n  {\n    CommentInfo: CommentInfo{\n      Content: \"content\",\n    },\n    PullRequestDiff: PullRequestDiff{\n      OriginalFilePath: index.js   \n      OriginalStartLine: 1\n      OriginalEndLine: 1\n      OriginalStartColumn: 1\n      OriginalEndColumn: 1  \n      NewFilePath: index.js        \n      NewStartLine: 1       \n      NewEndLine: 1         \n      NewStartColumn: 1     \n      NewEndColumn: 1       \n    },\n  }\n}\n\n\nerr := client.AddPullRequestReviewComments(ctx, owner, repository, pullRequestID, comments...)\n```\n\n##### List Pull Request Comments\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// Pull Request ID\npullRequestID := 5\n\npullRequestComments, err := client.ListPullRequestComment(ctx, owner, repository, pullRequestID)\n```\n\n##### List Pull Request Review Comments\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// Pull Request ID\npullRequestID := 5\n\npullRequestComments, err := client.ListPullRequestReviewComments(ctx, owner, repository, pullRequestID)\n```\n\n##### Delete Pull Request Comment\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// Pull Request ID\npullRequestID := 5\n// Comment ID\ncommentID := 17\n\nerr := client.DeletePullRequestComment(ctx, owner, repository, pullRequestID, commentID)\n```\n\n##### Delete Pull Request Review Comments\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// Pull Request ID\npullRequestID := 5\n// Comment ID\ncomments := []CommentInfo{\n  {\n    ID: 2\n    // For GitLab\n    ThreadID: 7\n  }\n}\n\nerr := client.DeletePullRequestComment(ctx, owner, repository, pullRequestID, comments...)\n```\n\n\n#### Get Commits\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// VCS branch\nbranch := \"dev\"\n\n// Commits information of the latest branch commits \ncommitInfo, err := client.GetCommits(ctx, owner, repository, branch)\n```\n\n#### Get Commits With Options\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n\n// Commits query options \noptions := GitCommitsQueryOptions{\n  Since: time.Date(2021, 1, 1, 0, 0, 0, 0, time.UTC),\n  Until: time.Now(),\n  ListOptions: ListOptions{\n\t  Page:    1,\n\t  PerPage: 30,\n    },\n  }\n\nresult, err := client.GetCommitsWithQueryOptions(ctx, owner, repository, options)\n```\n\n#### Get Latest Commit\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// VCS branch\nbranch := \"dev\"\n\n// Commit information of the latest commit\ncommitInfo, err := client.GetLatestCommit(ctx, owner, repository, branch)\n```\n\n#### Get Commit By SHA\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// SHA-1 hash of the commit\nsha := \"abcdef0123abcdef4567abcdef8987abcdef6543\"\n\n// Commit information of requested commit\ncommitInfo, err := client.GetCommitBySha(ctx, owner, repository, sha)\n```\n\n### \n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// Commit SHA\ncommitSHA := \"abcdef0123abcdef4567abcdef8987abcdef6543\"\n\n// List pull requests associated with a specific commit\npullRequests, err := client.ListPullRequestsAssociatedWithCommit(ctx, owner, repository, commitSHA)\n```\n\n#### Get List of Modified Files\n\nThe `refBefore...refAfter` syntax is used.\nMore about it can be found at [Commit Ranges](https://git-scm.com/book/en/v2/Git-Tools-Revision-Selection) Git\ndocumentation.\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// SHA-1 hash of the commit or tag or a branch name\nrefBefore := \"abcdef0123abcdef4567abcdef8987abcdef6543\"\n// SHA-1 hash of the commit or tag or a branch name\nrefAfter := \"main\"\n\nfilePaths, err := client.GetModifiedFiles(ctx, owner, repository, refBefore, refAfter)\n```\n\n#### Add Public SSH Key\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// An identifier for the key\nkeyName := \"my ssh key\"\n// The public SSH key\npublicKey := \"ssh-rsa AAAA...\"\n// Access permission of the key: vcsclient.Read or vcsclient.ReadWrite\npermission = vcsclient.Read\n\n// Add a public SSH key to a repository\nerr := client.AddSshKeyToRepository(ctx, owner, repository, keyName, publicKey, permission)\n```\n\n#### Get Repository Info\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n\n// Get information about repository\nrepoInfo, err := client.GetRepositoryInfo(ctx, owner, repository)\n```\n\n#### Get Repository Environment Info\n\nNotice - Get Repository Environment Info is currently supported on GitHub only.\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// Environment name\nname := \"frogbot\"\n\n// Get information about repository environment\nrepoEnvInfo, err := client.GetRepositoryEnvironmentInfo(ctx, owner, repository, name)\n```\n\n#### Create a label\n\nNotice - Labels are not supported in Bitbucket\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// Label info\nlabelInfo := LabelInfo{\n  Name:        \"label-name\",\n  Description: \"label description\",\n  Color:       \"4AB548\",\n}\n// Create a label\nerr := client.CreateLabel(ctx, owner, repository, labelInfo)\n```\n\n#### Get a label\n\nNotice - Labels are not supported in Bitbucket\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// Label name\nlabelName := \"label-name\"\n\n// Get a label named \"label-name\"\nlabelInfo, err := client.GetLabel(ctx, owner, repository, labelName)\n```\n\n#### List Pull Request Labels\n\nNotice - Labels are not supported in Bitbucket\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// Pull Request ID\npullRequestID := 5\n\n// List all labels assigned to pull request 5\npullRequestLabels, err := client.ListPullRequestLabels(ctx, owner, repository, pullRequestID)\n```\n\n#### Unlabel Pull Request\n\nNotice - Labels are not supported in Bitbucket\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// Label name\nname := \"label-name\"\n// Pull Request ID\npullRequestID := 5\n\n// Remove label \"label-name\" from pull request 5\nerr := client.UnlabelPullRequest(ctx, owner, repository, name, pullRequestID)\n```\n\n#### Upload Code Scanning\n\nNotice - Code Scanning is currently supported on GitHub only.\n\n```go\n// Go context\nctx := context.Background()\n// The account owner of the git repository\nowner := \"user\"\n// The name of the repository\nrepo := \"my_repo\"\n// The branch name for which the code scanning is relevant\nbranch := \"my_branch\"\n// A string representing the code scanning results\nscanResults := \"results\"\n\n// Uploads the scanning analysis file to the relevant git provider\nsarifID, err := client.UploadCodeScanning(ctx, owner, repo, branch, scanResults)\n```\n\n#### Download a File From a Repository\n\nNote - This API is currently not supported for Bitbucket Cloud.\n\n```go\n// Go context\nctx := context.Background()\n// The account owner of the git repository\nowner := \"user\"\n// The name of the repository\nrepo := \"my_repo\"\n// The branch name for which the code scanning is relevant\nbranch := \"my_branch\"\n// A string representing the file path in the repository\npath := \"path\"\n\n// Downloads a file from a repository\ncontent, statusCode, err := client.DownloadFileFromRepo(ctx, owner, repo, branch, path)\n```\n\n\n#### Create Branch\n\nNotice - Create Branch is currently supported on GitHub only.\n\n```go\n// Go Context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VSC Repository\nrepository := \"jfrog-cli\"\n// Source branch to create a new branch from\nsourceBranch := \"main\"\n// New branch name\nnewBranch := \"my-new-branch\"\n\n// Create a new branch\nerr = client.CreateBranch(ctx, owner, repository, sourceBranch, newBranch)\n```\n\n#### Allow Workflows\n\nNotice - Allow Workflows is currently supported on GitHub only.\n\n```go\n// Go context\nctx := context.Background()\n// Organization \nowner := \"jfrog\"\n\n// Allow workflows for the organization\nerr = client.AllowWorkflows(ctx, owner)\n```\n\n#### Add Organization Secret\n\nNotice - Add Organization Secrets currently supported on GitHub only.\n\n```go\n// Go context\nctx := context.Background()\n// Organization\nowner := \"jfrog\"\n// Secret name\nsecret := \"key\"\n// Secret value, will be encrypted by froggit\nsecretValue := \"some-secret-value\"\n\n// Add a secret to the organization\nerr = client.AddOrganizationSecret(ctx, owner, secret, secretValue)\n```\n\n#### Create Organization Variable\n\nNotice - Create Organization Variable is currently supported on GitHub only.\n\n```go\n// Go context\nctx := context.Background()\n// Organization\nowner := \"jfrog\"\n// Variable name\nvariableName := \"JF_URL\"\n// Variable value\nvariableValue := \"https://acme.jfrog.io/\"\n\n// Add a variable to the organization\nerr = client.CreateOrgVar(ctx, owner, variableName, variableValue)\n\n#### Get Repo Collaborators\n\nNotice - Get Repo Collaborators is currently supported on GitHub only.\n\n```go\n// Go context\nctx := context.Background()\n// Organization\nowner := \"jfrog\"\n// Repository name\nrepo := \"jfrog-cli\"\n// Affiliation type, can be one of the following: all, direct, outside, member\naffiliation := \"direct\"\n// Permission type, can be one of the following: read, write, admin, maintain, triage\npermission := \"maintain\"\n\n// Get the list of collaborators for a specific repository\ncollaborators, err := client.GetRepoCollaborators(ctx, owner, repo, affiliation, permission)\n```\n\n#### Get Repo Teams By Permissions\n\nNotice - Get Repo Teams By Permissions currently supported on GitHub only.\n\n```go\n// Go context\nctx := context.Background()\n// Organization\nowner := \"jfrog\"\n// Repository name\nrepo := \"jfrog-cli\"\n// Permission type, can be one of the following: read, write, admin, maintain, triage\npermissions := []string{\"maintain\", \"admin\"}\n\n// Get the list of teams with specific permissions for a repository\nteams, err := client.GetRepoTeamsByPermissions(ctx, owner, repo, permissions)\n```\n\n#### Create Or Update Environment\n\nNotice - Create Or Update Environment is currently supported on GitHub only.\n\n```go\n// Go context\nctx := context.Background()\n// Organization\nowner := \"jfrog-org\"\n// Repository name\nrepo := \"big-npm\"\n// Repository environment name\nenvName := \"frogbot\"\n// List of teams ids to add to the environment\nteams := []int64{12345678}\n// List of user names to add to the environment\nusers := []string{\"eyalk007\"}\n\t\n// Create or update the environment\nerr = client.CreateOrUpdateEnvironment(ctx, owner, repo, envName, teams, users)\n```\n\n#### Commit And Push Files\n\nNotice - Commit And Push Files is currently supported on GitHub only.\n\n```go\n// Go context\nctx := context.Background()\n// Organization\nowner := \"jfrog\"\n// Repository name\nrepo := \"jfrog-cli\"\n// Source branch name\nsourceBranch := \"feature-branch\"\n// Commit message\ncommitMessage := \"example commit message\" \n// Author name\nauthor := \"example\"\n//Files To commit\nfilesToCommit := []vcsclient.FileToCommit{{\n\t\tPath:    \".github/workflows/example.yml\",\n\t\tContent: \"hello world\",\n\t}}\n//Author email\nauthorEmail := \"example@gmail.com\"\n\n// Commit and push files to the repository in the source branch\nerr = client.CommitAndPushFiles(ctx, owner, repo, sourceBranch, commitMessage, author, authorEmail, filesToCommit)\n```\n\n#### Merge Pull Request\n\nNotice - Merge Pull Request is currently supported on GitHub only.\n\n```go\n// Go context\nctx := context.Background()\n// Organization\nowner := \"jfrog\"\n// Repository name\nrepo := \"jfrog-cli\"\n// pull request number\nprNumber := 134\n// Commit message, empty will use the default commit message\ncommitMessage := \"example commit message\"\n\n// Merge the pull request\nerr = client.MergePullRequest(ctx, owner, repo, prNumber, commitMessage)\n```\n\n#### Create Pull Request Detailed\n\nNotice - Create Pull Request Detailed is currently supported on GitHub only.\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// Source pull request branch\nsourceBranch := \"dev\"\n// Target pull request branch\ntargetBranch := \"main\"\n// Pull request title\ntitle := \"Pull request title\"\n// Pull request description\ndescription := \"Pull request description\"\n\n// Creates a pull request and returns its number and URL.\nprInfo,err := client.CreatePullRequestDetailed(ctx, owner, repository, sourceBranch, targetBranch, title, description)\n```\n\n#### Upload Snapshot To Dependency Graph\n\nNotice - Upload Snapshot To Dependency Graph is currently supported on GitHub only.\n\n```go\n// Go context\nctx := context.Background()\n// Organization or username\nowner := \"jfrog\"\n// VCS repository\nrepository := \"jfrog-cli\"\n// SBOM snapshot containing dependency information\nsnapshot := \u0026vcsclient.SbomSnapshot{\n    Version: 0,\n    Sha:     \"5c05522fecf8d93a11752ff255c99fcb0f0557cd\",\n    Ref:     \"refs/heads/main\",\n    Job: \u0026vcsclient.JobInfo{\n        Correlator: \"job-correlator\",\n        ID:         \"job-id\",\n    },\n    Detector: \u0026vcsclient.DetectorInfo{\n        Name:    \"detector-name\",\n        Version: \"1.0.0\",\n        Url:     \"https://example.com/detector\",\n    },\n    Scanned: time.Now(),\n    Manifests: map[string]*vcsclient.Manifest{\n        \"package.json\": {\n            Name: \"package.json\",\n            File: \u0026vcsclient.FileInfo{\n                SourceLocation: \"package.json\",\n            },\n            Resolved: map[string]*vcsclient.ResolvedDependency{\n                \"lodash\": {\n                    PackageURL:   \"pkg:npm/lodash@4.17.21\",\n                    Dependencies: []string{},\n                },\n            },\n        },\n    },\n}\n\n// Uploads the SBOM snapshot to the GitHub dependency graph tab\nerr := client.UploadSnapshotToDependencyGraph(ctx, owner, repository, snapshot)\n```\n\n### Webhook Parser\n\n```go\n// Go context\nctx := context.Background()\n// Logger\nlogger := vcsclient.EmptyLogger{}\n// Webhook contextual information\norigin := webhookparser.WebhookOrigin{\n  // The VCS provider (required)\n  VcsProvider: vcsutils.GitHub,\n  // Optional URL of the VCS provider (used for building some URLs)\n  OriginURL: \"https://api.github.com\",\n  // Token to authenticate incoming webhooks. If empty, signature will not be verified. \n  // The token is a random key generated in the CreateWebhook command. \n  Token: []byte(\"abc123\"),\n}\n// The HTTP request of the incoming webhook\nrequest := http.Request{}\n\nwebhookInfo, err := webhookparser.ParseIncomingWebhook(ctx, logger, origin, request)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjfrog%2Ffroggit-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjfrog%2Ffroggit-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjfrog%2Ffroggit-go/lists"}