Skip to main content

Git exploration utilities for xonsh.

Project description

xontrib-xgit

An xonsh command-line environment for exploring git repositories and histories.

This provides a set of commands that return objects for both display and pythonic manipulation.

If you like the idea click ⭐ on the repo and tweet.

Installation

To install use xpip:

xpip install xontrib-xgit
# or: xpip install -U git+https://github.com/BobKerns/xontrib-xgit

Usage

xontrib load xgit

Commands

git-cd (Command)

git-cd [path]

Update the git working directory (and the process working directory if the directory exists in the worktree).

If path is in a different worktree or repository, it will switch automatically to that worktree and repository.

With no arguments, returns to the root of the current repository.

git-pwd (Command)

git-pwd

Print information about the current git context, including:

  • repository; Repository path per worktree
  • common: Repository common path
  • worktree: Worktree root path
  • git_path: Path within the repository
  • branch: Current Branch
  • commit: Current commit
  • cwd: Working directory (what pwd would print)

This just returns (and displays) the XGIT variable if it is not None. In scripts you can just reference this variable directly.

XGIT (Variable)

The current GitContext. This is the same as the value returned from the git-pwd command.

It will be None when not inside a git worktree or repository.

XGIT_CONTEXTS (variable)

A dictionary of GitContext objects, one for every worktree or repository we have visited.

This allows one to switch between repositories without losing context.

git-ls (Command)

This returns the directory as an object which can be accessed from the python REPL:

>>> git-ls
_3: GitTree(c000f7a0a713b405fe0de6531fdbdfff3ff65d38)[7]
    - 569f95766c26158241a665763c76b93b103538b9     3207 .gitignore
    D 46b57ab337456176669e75513dbe0f5eeca38a22        1 .vscode
    - a3990ed1209000756420fae0ee6386e051204a60     1066 LICENSE
    - 505d8917cd9697185e30bb79238be4d84d02693e       50 README.md
    D 6f0c75cd8b53eeb83198dd5c6caea5361a240e20        2 bstring
    - 16494e4075e5cc44c5a928c7a325b8bc7bf552d5       23 requirements.txt
    D 05433255eddde7d3261f07a45b857374e6087278       10 xontrib-xgit
>>> _['README.md']
GitFile(- 505d8917cd9697185e30bb79238be4d84d02693e       50)
>>> _.hash
'505d8917cd9697185e30bb79238be4d84d02693e'

git_ls (Function)

The functional version of the git-ls command.

git_ls('xontrib-xgit')

Credits

This package was created with xontrib template.


Xontrib Promotion (DO and REMOVE THIS SECTION)

  • ✅ Check that your repository name starts from xontrib- prefix. It helps Github search find it.

  • ✅ Add xonsh, xontrib and other thematic topics to the repository "About" setting.

  • ✅ Add preview image in "Settings" - "Options" - "Social preview". It allows to show preview image in Github Topics and social networks e.g. Twitter.

  • ✅ Enable "Sponsorship" in "Settings" - "Features" - Check "Sponsorships".

  • Add xontrib to the awesome-xontribs.

  • Publish your xontrib to PyPi via Github Actions and users can install your xontrib via xpip install xontrib-myxontrib. Easiest way to achieve it is to use Github Actions. Register to https://pypi.org/ and create API token. Go to repository "Settings" - "Secrets" and your PyPI API token as PYPI_API_TOKEN as a "Repository Secret". Now when you create new Release the Github Actions will publish the xontrib to PyPi automatically. Release status will be in Actions section. See also .github/workflows/release.yml.

  • Write a message to: xonsh Gitter chat, Twitter, Reddit, Mastodon.

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

xontrib_xgit-0.0.1.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

xontrib_xgit-0.0.1-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file xontrib_xgit-0.0.1.tar.gz.

File metadata

  • Download URL: xontrib_xgit-0.0.1.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for xontrib_xgit-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7772161e115faa92956cbc3fa9fa144a917fea5af858f2b9a50c29e98347f06e
MD5 6c78d550ccfa6d45b71bee22356b4e36
BLAKE2b-256 9ead21900eae3e538955000451598db79241752cb8d0c1287910a7704e467a4b

See more details on using hashes here.

File details

Details for the file xontrib_xgit-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for xontrib_xgit-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 48c20ec30f089610bec108683d00dd23cf3b5a281462744363caba29bc1235ba
MD5 668fb807980dfd01fe3648a36c5e45f5
BLAKE2b-256 c7aac9f0398aee1ee144791eff04b2abe6334a5adeb17592abcf3300f15f9a95

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