How paulirish/git-open works
Purpose and Entry Points
git-open is a shell-based Git subcommand that resolves the current repository, remote, branch, commit, or issue into a hosted-repository URL and opens it in the system browser. The primary executable is git-open; Git discovers it as git open when it is on PATH.
• git-open
• git-open.1.md
• package.json
CLI Dispatch and Git Context Resolution
The executable parses positional remote/branch arguments and mode flags including commit, issue, print-only, and URL suffix behavior. It interrogates the local Git repository for its tracked/default remote, branch, and commit state. --print is the output boundary: it emits the resolved URL without launching a browser.
• git-open
• git-open.1.md
Remote Normalization and Provider Routing
Remote URLs may be SSH or HTTPS and are normalized into host, owner/project, and provider-specific path information. The central routing responsibility selects URL conventions for GitHub/Gist, GitLab including custom instances, Bitbucket Cloud/Server, VSTS/TFS, AWS CodeCommit, and cnb.cool. Provider differences determine branch, commit, issue, and suffix paths.
• git-open
• README.md
URL Construction Modes
After remote/provider resolution, the command builds a repository-web URL for one of four primary targets: a branch page (default), current commit, issue inferred from an issue-style branch name, or a caller-provided suffix such as pulls. Issue opening is intentionally limited to providers with supported issue URL formats.
• git-open
• git-open.1.md
Browser Launch Boundary
The final URL is either printed or delegated to platform-appropriate browser-opening behavior. This isolates OS/runtime concerns from Git parsing and URL construction, including shell environments and Windows/WSL installation paths.
• git-open
• git-open.plugin.sh
• git-open.plugin.zsh
Distribution and Shell Integration
The project ships as a standalone executable, an npm global package, and Bash/Zsh plugin entry files. Shell plugins expose the command within plugin managers, while npm packaging distributes the same command-line artifact rather than a Node runtime application.
• package.json
• git-open.plugin.sh
• git-open.plugin.zsh
Verification and Automation
Behavior is validated with BATS shell tests, including assertion/support dependencies included as Git submodules. GitHub Actions runs repository CI; Node/npm is used primarily to expose test scripts and package distribution metadata.
• test/git-open.bats
• test/test_helper/bats-assert
• .github/workflows/ci.yml
Main entry points: git-open git-open executable · git-open.bats BATS behavior tests · package.json npm package · git-open.1.md CLI manual
Components 16
CLI Runtime
- Git / local repository · Supplies remotes, branch, and commit state.
- git-open executable · Git-discoverable git-open command.
git-open - Argument dispatch · Selects remote, target mode, print behavior, and suffix.
git-open - Git context resolution · Finds tracked/default remote, branch, and commit.
git-open - Remote normalization · Converts SSH or HTTPS remotes into host and project data.
git-open - Provider routing · Applies GitHub, GitLab, Bitbucket, VSTS/TFS, CodeCommit, and cnb.cool conventions.
git-open - Target URL construction · Builds branch, commit, supported issue, or suffix URLs.
git-open - Print-only output · Emits the URL when --print is selected.
git-open - Browser launcher · Opens the resolved URL with OS and WSL-aware behavior.
git-open - CLI manual
git-open.1.md
Distribution
- npm package · Publishes the shell executable and npm scripts.
package.json - Bash plugin entry
git-open.plugin.sh - Zsh plugin entry
git-open.plugin.zsh
Verification
- BATS behavior tests
test/git-open.bats - BATS assertion support · Assertion and support dependency included as a Git submodule.
test/test_helper/bats-assert - GitHub Actions CI
.github/workflows/ci.yml
Connections 18
- git-open executable → Argument dispatch: parses
- Argument dispatch → Git context resolution: requests context
- Git / local repository → Git context resolution: remote and HEAD state
- Git context resolution → Remote normalization: remote URL
- Remote normalization → Provider routing: host and project
- Argument dispatch → Target URL construction: selected mode
- Git context resolution → Target URL construction: branch or commit
- Provider routing → Target URL construction: provider paths
- Target URL construction → Print-only output: --print
- Target URL construction → Browser launcher: default URL opening
- npm package → git-open executable: distributes
- Bash plugin entry → git-open executable: exposes
- Zsh plugin entry → git-open executable: exposes
- CLI manual → git-open executable: documents
- BATS behavior tests → git-open executable: validates
- BATS behavior tests → BATS assertion support: uses
- GitHub Actions CI → BATS behavior tests: runs
- npm package → BATS behavior tests: test script