Skip to main content

A CLI tool and also a Python library can print the url of a local file in a git repo so you can one-click to open it in web browser.

Project description

Documentation Status https://github.com/MacHu-GWU/git_web_url-project/actions/workflows/main.yml/badge.svg https://codecov.io/gh/MacHu-GWU/git_web_url-project/branch/main/graph/badge.svg https://img.shields.io/pypi/v/git-web-url.svg https://img.shields.io/pypi/l/git-web-url.svg https://img.shields.io/pypi/pyversions/git-web-url.svg https://img.shields.io/badge/✍️_Release_History!--None.svg?style=social&logo=github https://img.shields.io/badge/⭐_Star_me_on_GitHub!--None.svg?style=social&logo=github
https://img.shields.io/badge/Link-API-blue.svg https://img.shields.io/badge/Link-Install-blue.svg https://img.shields.io/badge/Link-GitHub-blue.svg https://img.shields.io/badge/Link-Submit_Issue-blue.svg https://img.shields.io/badge/Link-Request_Feature-blue.svg https://img.shields.io/badge/Link-Download-blue.svg

Welcome to git_web_url Documentation

https://git-web-url.readthedocs.io/en/latest/_static/git_web_url-logo.png

git_web_url is a CLI tool and also a Python library that prints the URL of a local file in a git repo so you can one-click to open it in web browser.

Currently it supports:

Git Hosting Services:

  • GitHub

  • GitHub Enterprise

  • GitLab

  • GitLab Enterprise

  • BitBucket

  • BitBucket Enterprise

  • AWS CodeCommit

Git Clone Protocols:

CLI Usage

Basic Usage

cd into your git repo directory, or any folder inside, then run gwu (or gitweburl). It prints the URL for the current branch and current directory:

$ gwu
https://github.com/your_account/your_repo/tree/your_branch/path/to/current_directory

Specify a File or Folder

Provide the absolute path of the file or folder in your local git repo:

$ gwu /path/to/your_repo/path/to/your_file.py
https://github.com/your_account/your_repo/blob/your_branch/path/to/your_file.py

Branch Options

Use the --branch (or -b) flag to control which branch appears in the URL:

# Use current branch (default behavior)
$ gwu
https://github.com/your_account/your_repo/tree/feature-branch/

# Use default branch (main/master) - URL without explicit branch
$ gwu --branch=default
https://github.com/your_account/your_repo

# Use a specific branch
$ gwu --branch=main
https://github.com/your_account/your_repo/tree/main/

# Short form
$ gwu -b develop
https://github.com/your_account/your_repo/tree/develop/

Python API Usage

You can also use git_web_url as a Python library:

from pathlib import Path
import git_web_url.api as gwu

# Get URL for a file using current branch
url = gwu.get_web_url(Path("/path/to/your_repo/file.py"))

# Get URL using default branch (main/master)
url = gwu.get_web_url(
    Path("/path/to/your_repo/file.py"),
    branch=gwu.DEFAULT_BRANCH,
)

# Get URL using a specific branch
url = gwu.get_web_url(
    Path("/path/to/your_repo/file.py"),
    branch="feature-branch",
)

Install

git_web_url is released on PyPI, so all you need is to:

$ pip install git-web-url

To upgrade to latest version:

$ pip install --upgrade git-web-url

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

git_web_url-0.1.4.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_web_url-0.1.4-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file git_web_url-0.1.4.tar.gz.

File metadata

  • Download URL: git_web_url-0.1.4.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for git_web_url-0.1.4.tar.gz
Algorithm Hash digest
SHA256 1e76b4c1ced389dcd13351fce48d828ca022545fb289517b5d61e8a6dba46572
MD5 0d000f56611341e0115a91be6d78e6a8
BLAKE2b-256 5c263409f4feeffdc549f6caaf943bdf3832be4e24b6a030229aca376fd525c0

See more details on using hashes here.

File details

Details for the file git_web_url-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: git_web_url-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for git_web_url-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 34b3414cca4b6f3ef7b8f2fe613aa53ea0d86bfef11db110ef6f3b737e3005ed
MD5 a4d81da1b505d31bb0e828a7e18256ea
BLAKE2b-256 7dc8dfb1504e0a7b04c0882b9586e3ed55a27c19e2d0a6e938ba8fd064cebd13

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page