{"id":43052504,"url":"https://github.com/cloud-native-toolkit/git-client","last_synced_at":"2026-01-31T10:38:05.035Z","repository":{"id":37760274,"uuid":"428539793","full_name":"cloud-native-toolkit/git-client","owner":"cloud-native-toolkit","description":"Client to interact with different Git server apis","archived":false,"fork":false,"pushed_at":"2023-07-05T18:12:23.000Z","size":1606,"stargazers_count":0,"open_issues_count":11,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-10-22T05:49:20.907Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloud-native-toolkit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-11-16T06:16:35.000Z","updated_at":"2022-01-03T16:01:53.000Z","dependencies_parsed_at":"2024-10-24T09:38:32.884Z","dependency_job_id":"f06e26e9-6167-438e-828b-d743a6da9397","html_url":"https://github.com/cloud-native-toolkit/git-client","commit_stats":{"total_commits":133,"total_committers":3,"mean_commits":"44.333333333333336","dds":0.3007518796992481,"last_synced_commit":"546e3ce17e7b55c3dd98cee6d2a58a852ef6274c"},"previous_names":[],"tags_count":76,"template":false,"template_full_name":null,"purl":"pkg:github/cloud-native-toolkit/git-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud-native-toolkit%2Fgit-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud-native-toolkit%2Fgit-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud-native-toolkit%2Fgit-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud-native-toolkit%2Fgit-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloud-native-toolkit","download_url":"https://codeload.github.com/cloud-native-toolkit/git-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloud-native-toolkit%2Fgit-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28938831,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T10:18:23.202Z","status":"ssl_error","status_checked_at":"2026-01-31T10:18:22.693Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2026-01-31T10:38:04.973Z","updated_at":"2026-01-31T10:38:05.022Z","avatar_url":"https://github.com/cloud-native-toolkit.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Git client\n\nSDK to interact with different git servers using a consistent api.\n\n\n## CLI installation\n\nTo install the latest version of gitu into `/usr/local/bin`, run the following:\n\n```shell\ncurl -sL https://gitu.cloudnativetoolkit.dev/install.sh | sh\n```\n\nIf you would like to install the CLI in a different directory, use the following:\n\n```shell\ncurl -sL https://gitu.cloudnativetoolkit.dev/install.sh | DEST_DIR=~/bin sh\n```\n\n## Usage\n\nThe SDK will determine the type of repo given the url to the server and return a `GitApi` instance that implements the apis for that server. The url can point to a specific repository or to an organization.\n\nThe api can be loaded using the `apiFromUrl` helper function:\n\n```javascript\nimport {apiFromUrl} from 'git-client'\n\nconst api: GitApi = apiFromUrl('https://github.com/org/repo', {username, password})\n```\n\nFrom there, any of the implemented apis can be called. For example:\n\n```javascript\napi.createWebhook({webhookUrl: 'https://webhook'})\n```\n\n### Provided CLI commands\n\n#### create\n\nCreates a git repo from the provided information\n\n```shell\nexport GIT_USERNAME=\"myuser\"\nexport GIT_TOKEN=\"xxx\"\ngitu create my-repo -h github.com\n```\n\nTo create the repo in a different org, include the `-o` flag\n\n```shell\nexport GIT_USERNAME=\"myuser\"\nexport GIT_TOKEN=\"xxx\"\ngitu create my-repo -h github.com -o myorg\n```\n\n#### exists\n\nChecks if a given repo exists and return some information about it.\n\n```shell\nexport GIT_USERNAME=\"myuser\"\nexport GIT_TOKEN=\"xxx\"\ngitu exists https://github.com/myuser/my-repo\n```\n\nor you can check for the repo using the parts of the url\n\n```shell\nexport GIT_USERNAME=\"myuser\"\nexport GIT_TOKEN=\"xxx\"\ngitu exists my-repo -h github.com\n```\n\n#### delete\n\nDeletes the provided repo\n\n```shell\nexport GIT_USERNAME=\"myuser\"\nexport GIT_TOKEN=\"xxx\"\ngitu delete https://github.com/myuser/my-repo\n```\n\nor you can delete the repo using the parts of the url\n\n```shell\nexport GIT_USERNAME=\"myuser\"\nexport GIT_TOKEN=\"xxx\"\ngitu delete my-repo -h github.com\n```\n\n#### clone\n\nClones the repository, handling the credentials and the name and email config\n\n```shell\nexport GIT_USERNAME=\"myuser\"\nexport GIT_TOKEN=\"xxx\"\ngitu clone https://github.com/myuser/my-repo\n```\n\nor you can clone the repo using the parts of the url\n\n```shell\nexport GIT_USERNAME=\"myuser\"\nexport GIT_TOKEN=\"xxx\"\ngitu clone my-repo -h github.com\n```\n\n### Provided APIs\n\nThe exposed APIs are defined in `lib/git.api.ts` in the `GitApi` abstract class. The available API functions are:\n\n- `createRepo()` - creates a repository in the org\n- `deleteRepo()` - deletes the repository\n- `getWebhooks()` - list the defined webhooks\n- `createWebhook()` - create a webhook on the repository\n- `deleteBranch()` - deletes a branch in the repository\n- `rebaseBranch()` - rebases a branch on top of another one in the repository\n- `getPullRequest()` - retrieves a pull request from the repository\n- `createPullRequest()` - creates a pull request in the repository for a given branch\n- `mergePullRequest()` - merges the given pull request\n- `updateAndMergePullRequest()` - updates the pull request with the latest from the target branch and merges it\n- `updatePullRequestBranch()` - updates the pull request with the latest from the target branch\n- `clone()` - clones the repository to the local file system\n\n### Command-line credentials\n\nCredentials can be provided to the command-line for each command using the `-u` and `--token` argument OR the credentials can be stored in a configuration file for each host.\n\nThe configuration file is named `.gitu-config` and should be stored in the home directory. Each entry should contain the `host`, `username` and `token`. Optionally, if the git server uses a self-signed certificate it can also be provided to the configuration with the `caCert` value.\n\nFor example:\n\n```yaml\ncredentials:\n- host: github.com\n  username: myuser\n  token: token\n- host: git.myhost.com\n  username: githuser\n  token: token\n  caCert: /path/to/ca.crt\n```\n\n## Testing\n\nThe repository provides unit tests and integration tests. The unit tests can be run independently of any Git hosts. The integration tests require configuration, including credentials, in order to run.\n\n### Unit tests\n\nTo execute the unit tests, run the following:\n\n```shell\nnpm test\n```\n\n### Integration tests\n\nThe integration test runner will execute any files that match the pattern `*.ispec.ts`. To run the integration tests:\n\n1. Copy `.env.template` to `.env` and provide values for the environment variables for the repositories you want to test. If environment variables are missing for a type of repository then it will be skipped (or you can skip testing a type of repository by setting XXX_SKIP=\"true\")\n2. Run the following command:\n\n    ```shell\n    npm run test:integration\n    ```\n   \n**Note:** The integration tests will create a repository, execute some APIs, then delete the repository. The Personal Access Token provided for the `XXX_PASSWORD` environment variable needs to have enough permission to delete the repo.\n\n## Notes\n\n- clone {url} [{path}] (include name and email config)\n- pr create\n- pr merge\n- pr get\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloud-native-toolkit%2Fgit-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloud-native-toolkit%2Fgit-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloud-native-toolkit%2Fgit-client/lists"}