{"id":16295129,"url":"https://github.com/wadackel/go-gitcmd","last_synced_at":"2025-04-05T20:32:35.109Z","repository":{"id":57481323,"uuid":"120305259","full_name":"wadackel/go-gitcmd","owner":"wadackel","description":"Go (golang) package providing for tiny git command wrapper.","archived":false,"fork":false,"pushed_at":"2018-02-05T14:57:42.000Z","size":5,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-21T09:51:05.604Z","etag":null,"topics":["git","go","golang","golang-package"],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/tsuyoshiwada/go-gitcmd","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wadackel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-05T13:00:11.000Z","updated_at":"2020-11-17T21:49:28.000Z","dependencies_parsed_at":"2022-09-26T17:50:43.899Z","dependency_job_id":null,"html_url":"https://github.com/wadackel/go-gitcmd","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wadackel%2Fgo-gitcmd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wadackel%2Fgo-gitcmd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wadackel%2Fgo-gitcmd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wadackel%2Fgo-gitcmd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wadackel","download_url":"https://codeload.github.com/wadackel/go-gitcmd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399818,"owners_count":20932875,"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":["git","go","golang","golang-package"],"created_at":"2024-10-10T20:17:43.417Z","updated_at":"2025-04-05T20:32:34.672Z","avatar_url":"https://github.com/wadackel.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-gitcmd\n\n[![godoc.org](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](https://godoc.org/github.com/tsuyoshiwada/go-gitcmd)\n[![Travis](https://img.shields.io/travis/tsuyoshiwada/go-gitcmd.svg?style=flat-square)](https://travis-ci.org/tsuyoshiwada/go-gitcmd)\n[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/tsuyoshiwada/go-gitcmd/blob/master/LICENSE)\n\n\u003e Go (golang) package providing for tiny git command wrapper.\n\n\n\n\n## Installation\n\nTo install `go-gitcmd`, simply run:\n\n```bash\n$ go get -u github.com/tsuyoshiwada/go-gitcmd\n```\n\n\n\n\n## Usage\n\nIt is the simplest example.\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"github.com/tsuyoshiwada/go-gitcmd\"\n)\n\nfunc main() {\n\tgit := gitcmd.New(nil) // or `git := gitcmd.New(\u0026Config{Bin: \"/your/custom/git/bin\"})`\n\n\tout, err := git.Exec(\"rev-parse\", \"--git-dir\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfmt.Println(out) // \".git\"\n}\n```\n\nSee [godoc](https://godoc.org/github.com/tsuyoshiwada/go-gitcmd) for API detail :+1:\n\n\n\n\n## How to Mock\n\nSince `Client` is an interface, it can easily be Mocked.\n\n```go\ntype MockClient struct {\n\tgitcmd.Client // Interface embedding\n\tReturnCanExec        func() error\n\tReturnExec           func(string, ...string) (string, error)\n\tReturnInsideWorkTree func() error\n}\n\nfunc (m *MockClient) CanExec() error {\n\treturn m.ReturnCanExec()\n}\n\nfunc (m *MockClient) Exec(subcmd string, args ...string) (string, error) {\n\treturn m.ReturnExec(subcmd, args...)\n}\n\nfunc (m *MockClient) InsideWorkTree() error {\n\treturn m.ReturnInsideWorkTree()\n}\n\nfunc main() {\n\tgit := \u0026MockClient{}\n\n\t// Set `InsideWorkTree()` mock function\n\tgit.ReturnInsideWorkTree = func() error {\n\t\treturn errors.New(\"error...\")\n\t}\n\n\terr := git.InsideWorkTree()\n\tfmt.Println(err.Error()) // \"error...\"\n}\n```\n\n\n\n\n## Contribute\n\n1. Fork (https://github.com/tsuyoshiwada/go-gitcmd)\n1. Create a feature branch\n1. Commit your changes\n1. Rebase your local changes against the master branch\n1. Run test suite with the `go test` command and confirm that it passes\n1. Create new Pull Request :muscle:\n\nBugs, feature requests and comments are more than welcome in the [issues](https://github.com/tsuyoshiwada/go-gitcmd/issues).\n\n\n\n\n## License\n\n[MIT © tsuyoshiwada](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwadackel%2Fgo-gitcmd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwadackel%2Fgo-gitcmd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwadackel%2Fgo-gitcmd/lists"}