{"id":26581531,"url":"https://github.com/nikolainobadi/nngitkit","last_synced_at":"2026-04-12T18:02:35.636Z","repository":{"id":283876510,"uuid":"952766294","full_name":"nikolainobadi/NnGitKit","owner":"nikolainobadi","description":"Streamlined Git and GitHub command management with easy-to-use Swift interfaces.","archived":false,"fork":false,"pushed_at":"2025-03-22T18:13:10.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-22T19:20:37.696Z","etag":null,"topics":["cli","command-line-tool","developer-tools","git","github","github-actions","macos","shell","swift","swift-package","swift-package-manager"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/nikolainobadi.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":"2025-03-21T21:01:15.000Z","updated_at":"2025-03-22T18:13:13.000Z","dependencies_parsed_at":"2025-03-22T19:31:38.162Z","dependency_job_id":null,"html_url":"https://github.com/nikolainobadi/NnGitKit","commit_stats":null,"previous_names":["nikolainobadi/nngitkit"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikolainobadi%2FNnGitKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikolainobadi%2FNnGitKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikolainobadi%2FNnGitKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikolainobadi%2FNnGitKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nikolainobadi","download_url":"https://codeload.github.com/nikolainobadi/NnGitKit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245067689,"owners_count":20555612,"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":["cli","command-line-tool","developer-tools","git","github","github-actions","macos","shell","swift","swift-package","swift-package-manager"],"created_at":"2025-03-23T07:20:16.443Z","updated_at":"2026-04-12T18:02:35.620Z","avatar_url":"https://github.com/nikolainobadi.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NnGitKit\n\n![CI](https://github.com/nikolainobadi/NnGitKit/actions/workflows/ci.yml/badge.svg)\n![Swift Version](https://badgen.net/badge/swift/6.0%2B/purple)\n![Platform](https://img.shields.io/badge/Platform-macOS-lightgrey)\n![SPM](https://img.shields.io/badge/Distribution-SPM%20only-red)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\nNnGitKit is a Swift package designed to simplify interactions with Git and the GitHub CLI (`gh`). I built this package because I can never remember all the different commands available, and I wanted a more intuitive way to work with Git and GitHub directly from Swift.  \n\nThe package wraps common Git and GitHub operations in easy-to-use commands, making it quick to initialize repositories, manage branches, push changes, and more.  \n\n\u003e **Note:** This package is a work in progress. I add new commands as I find a need for them. Contributions and feedback are welcome!  \n\n## Features\n\n- Simplified Git initialization and commits  \n- Remote repository management with GitHub CLI integration  \n- Branch management and cleanup  \n- Command generation for both Git and GitHub operations  \n- Extensible design to easily add new commands  \n\n## Installation\n\nAdd the package to your Swift project using Swift Package Manager:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/nikolainobadi/NnGitKit.git\", from: \"0.6.0\")\n],\ntargets: [\n    .target(\n        name: \"YourApp\",\n        dependencies: [\n            // Use only this if you need GitShellKit (it exports GitCommandGen)\n            .product(name: \"GitShellKit\", package: \"NnGitKit\"),\n            \n            // Alternatively, use this directly if you only need GitCommandGen\n            .product(name: \"GitCommandGen\", package: \"NnGitKit\"),\n        ]\n    )\n]\n```\n\n## Usage\n\n## Creating Git Commands and GitHub Commands\n\nYou can create Git and GitHub commands using `GitShellCommand` and `GitHubShellCommand`, respectively.  \nThese commands generate shell-compatible strings that you can execute with any shell implementation.  \n\n```swift\nimport GitCommandGen\n\n// Creating a Git command to initialize a new repository\nlet initCommand = makeGitCommand(.gitInit, path: \"/path/to/project\")\nprint(\"Git Init Command: \\(initCommand)\")\n\n// Creating a GitHub command to create a remote repository\nlet createRepoCommand = makeGitHubCommand(.createRemoteRepo(name: \"MyAwesomeRepo\", visibility: \"public\", details: \"An awesome repo\"), path: \"/path/to/project\")\nprint(\"GitHub Create Repo Command: \\(createRepoCommand)\")\n\n```\n\n## Using Default Methods in GitShell\n\nNnGitKit includes some default methods for common Git operations. One of the most useful is `getRemoteURL`, which correctly maps the output of a standard Git remote URL to an HTTPS URL.  \n\n```swift\n// Using the default GitShell methods to get a remote URL\nlet shell = GitShellAdapter()\n\ndo {\n    let url = try shell.getGitHubURL(at: \"/path/to/project\")\n    print(\"GitHub URL: \\(url)\")\n} catch {\n    print(\"Error fetching GitHub URL: \\(error)\")\n}\n\n// Original output from Git: git@github.com:username/repo.git\n// Transformed URL: https://github.com/username/repo\n\n```\n\nTo resolve the default branch configured for a repository path:\n\n```swift\nlet defaultBranch = try shell.getDefaultBranch(at: \"/path/to/project\")\nprint(\"Default branch: \\(defaultBranch)\")\n```\n\nYou can also plan commands without executing them using `ExecutionMode.dryRun`:\n\n```swift\nlet gitStarter = GitStarter(path: \"/path/to/project\", shell: YourShellImplementation())\nlet planned = try gitStarter.gitInit(mode: .dryRun)\nprint(planned) // [\"git -C \\\"/path/to/project\\\" rev-parse --is-inside-work-tree\", ...]\n```\n\nWhen a command fails, `GitCommandFailure` includes the command string and any available output to aid diagnostics.\n\n### Initializing a Git Repository\n\n```swift \nimport NnGitKit\n\nlet gitStarter = GitStarter(path: \"/path/to/project\", shell: YourShellImplementation())\n\ndo {\n    try gitStarter.gitInit()\n    print(\"Repository initialized successfully.\")\n} catch {\n    print(\"Failed to initialize repository: \\(error)\")\n}\n\n```\n\n### Creating a GitHub Repository\n\n```swift\nlet info = RepoInfo(\n    name: projectName,\n    details: projectDetails,\n    visibility: visibility,\n    branchPolicy: .mainOnly,\n    defaultBranch: \"main\" // customize if your repo uses a different default branch\n)\nlet repoStarter = GitHubRepoStarter(path: \"/path/to/project\", shell: YourShellImplementation(), repoInfo: info)\n\ndo {\n    let url = try repoStarter.repoInit()\n    print(\"Repository created at \\(url)\")\n} catch {\n    print(\"Error creating repository: \\(error)\")\n}\n```\n\n## Using SwiftShell for Shell Operations (optional)\n\nAlthough NnGitKit is shell-agnostic, you can easily use it with **[SwiftShell](https://github.com/kareman/SwiftShell)** to handle shell operations.  \nHere’s an example of creating a `GitShellAdapter` that leverages SwiftShell to execute commands:\n\n```swift\nimport SwiftShell\nimport GitShellKit\n\n/// An adapter that uses SwiftShell to execute Git commands.\nstruct GitShellAdapter: GitShell {\n    func runWithOutput(_ command: String) throws -\u003e String {\n        let output = run(bash: command)\n        \n        if output.succeeded {\n            return output.stdout\n        } else {\n            throw output.error ?? NSError(domain: \"GitShellAdapterError\", code: 1, userInfo: nil)\n        }\n    }\n}\n```\n\n### Usage Example\n\n```swift\nlet shell = GitShellAdapter()\nlet gitStarter = GitStarter(path: \"/path/to/project\", shell: shell)\n\ndo {\n    try gitStarter.gitInit()\n    print(\"Repository initialized successfully.\")\n} catch {\n    print(\"Failed to initialize repository: \\(error)\")\n}\n```\n\n## Contributing\n\nFeel free to submit issues or pull requests. If you have ideas for new commands or improvements, I’d love to hear from you!\n\n## License\n\nNnGitKit is available under the MIT license. See the [LICENSE](LICENSE) file for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikolainobadi%2Fnngitkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikolainobadi%2Fnngitkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikolainobadi%2Fnngitkit/lists"}