Skip to main content

A tiny (yocto) git client for MicroPython.

Project description

A tiny (yocto) git client for MicroPython.

Install

$ ampy -p /dev/ttyUSB0 put ygit.py

Get Started

To clone a repo, run:

>>> ygit.clone('https://github.com/turfptax/ugit_test.git','.')

The second argument is the target directory (usually '.'). This will produce a shallow clone (at HEAD) by default. It will not delete any files in the target directory, but it will overwrite them if conflicting. The normal git files you’d expect (config, *.pack, IDX) will be in .ygit. You only need to run this once.

To update:

>>> ygit.pull('.')

Which is the same as:

>>> ygit.fetch('.')
>>> ygit.checkout('.')

These are incremental operations. It will only download git objects you don’t already have, and only update files when their SHA1 values don’t match.

API

ygit.init(repo, directory, cone=None)
ygit.clone(repo, directory, shallow=True, cone=None, quiet=False, commit='HEAD')
ygit.checkout(directory, commit='HEAD')
ygit.pull(directory, shallow=True, quiet=False, commit='HEAD')
ygit.fetch(directory, shallow=True, quiet=False, commit='HEAD')

Shallow Cloning

By default clones are shallow to save space.

Subdirectory Cloning

Usually I don’t want to clone an entire project onto my ESP32. The python I want on the device is in a subdirectory of a larger project. The cone argument will take a path, and only files in that directory will be checked out (as if it were the top level).

Design

This is a partial git client implemented in pure python, targeting MicroPython. It speaks to HTTP servers using the smart client protocol.

Roadmap

  • HTTP authentication for non-public projects.

  • clone is currently unfinished.

  • Support branches / tags.

Tests

  • pytest test_localhost.py (run nginx -c "$(pwd)/test_nginx.conf" -e stderr in the background)

  • pytest test_gh.py (runs tests against github)

  • pytest test_esp32.py (WARNING: will wipe all files except boot.py from your device.)

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

ygit-0.1.1.tar.gz (20.7 kB view hashes)

Uploaded Source

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