Skip to main content

Prints the forge url for a given file of a Git repository checkout

Project description

git-uff

Prints the forge URL for a given file of a Git repository checkout.

Intro

Have you ever been discussing with colleagues over IRC/Slack/Matrix/whatever about source code and found yourself needing to point them to a particular file in a git repository?

This is tedious to do.

One solution is to tell them the path in their checkout, hoping they are on the same branch as you.

Another solution is to point your browser to the forge hosting your git repository, select the right branch, navigate the file hierarchy, find your file and copy the file URL.

A better (in my opinion 😉) solution is to use git-uff. This tool adds an uff (short for "URL for file") git sub-command, which takes the path to a file in your repository checkout and prints the matching forge URL.

For example to print the URL of the src/linux/nanonote.desktop file from my Nanonote project:

$ git uff src/linux/nanonote.desktop
https://github.com/agateau/nanonote/blob/master/src/linux/nanonote.desktop

You can also point them to a specific line with the -l argument:

$ git uff src/linux/nanonote.desktop -l 10
https://github.com/agateau/nanonote/blob/master/src/linux/nanonote.desktop#L10

git-uff has a few other available options. Here is its --help output:

usage: git-uff [-h] [-b BRANCH] [-p] [-c] [-l LINE] path

Prints the forge URL for a given file or path of a Git repository checkout.

positional arguments:
  path                  File for which we want the URL

optional arguments:
  -h, --help            show this help message and exit
  -b BRANCH, --branch BRANCH
                        Use branch BRANCH instead of the current one
  -p, --permalink       Replace the branch in the URL with the commit it
                        points to
  -c, --copy            Copy the result to the clipboard
  -l LINE, --line LINE  Line to point to

New forges can be declared in git configuration. You can do so using
`git config`, like this:

    git config --global uff.<forge_base_url>.forge <forge>

Where <forge> must be one of: cgit, github, gitlab, sourcehut.

For example to declare that example.com uses GitLab:

    git config --global uff.example.com.forge gitlab

What if my code is not on GitHub?

git-uff is not tied to GitHub. It supports GitLab, SourceHut and CGit forges.

To declare a new forge, add it to your git configuration with:

git config --global uff.<forge_base_url>.forge <forge>

For example to declare that example.com uses GitLab:

git config --global uff.example.com.forge gitlab

See the output of git uff --help for the valid <forge> values.

Installation

The recommended method to install git-uff is to use pipx:

pipx install git-uff

But you can also install it with pip:

pip install --user git-uff

License

Apache 2.0

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-uff-0.3.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

git_uff-0.3.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file git-uff-0.3.0.tar.gz.

File metadata

  • Download URL: git-uff-0.3.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.8.10 Linux/5.11.0-46-generic

File hashes

Hashes for git-uff-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e51e2451e8bdc6f75be1b40fd415061c5d080a9c675d0178597431b1d8aa2f44
MD5 4fd6f1feab7b12b88effc24676f24ff8
BLAKE2b-256 a8ab6c10772678024527117099c2113117698c4ac9678d25438ad2e062a691cf

See more details on using hashes here.

File details

Details for the file git_uff-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: git_uff-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.8.10 Linux/5.11.0-46-generic

File hashes

Hashes for git_uff-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5773b2875825b1106983a3a1b29fa40755d88669941a409ffa1949ebba22e1d
MD5 e5ea6cc9e4aec73d54d52d43fb04566e
BLAKE2b-256 3b92cdbdc5dd86a5b8375342bb58ae88f7107e56072a2c2ae24ba4fa1af4ae66

See more details on using hashes here.

Supported by

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