Skip to main content

Simply Github

A simple tool for working with Github remotely. The basic interface is minimal. With Simply Github, you can:

  • Create and delete branches.

  • Add or remove files from a branch.

  • Merge branches.

Profiles

Pretty much every Simply Github function needs a profile as its first argument. A profile provides Simply Github with two pieces of information. It tells Simply Github:

  • The repo it should connect to.

  • The token it should connect with.

The repo is the name of a repo in the standard git form of :owner/:repo – for instance, jtpaasch/simplygithub.

The token is a valid personal access token, which you can create from your Github account, under account settings. See https://help.github.com/articles/creating-an-access-token-for-command-line-use

To generate a profile to use just during a coding session, import the simplygithub.authentication.profile package and use the ephemeral_profile() function. For example:

from simplygithub.authentication import profile

my_profile = profile.ephemeral_profile(repo="jtpaasch/simplygithub",
                                       token="a3ef21ac0f...")

You can then use my_profile for any of the Simply Github functions that need a profile.

An ephemeral profile only lasts for the coding session though. It disappears when the my_profile variable disappears. If you want to store a profile in a config file, use the write_profile() function.

That function takes the aforementioned repo and token arguments, but you also need to give the profile a name so you can retrieve it later.

This creates the same profile as above, but names it default:

from simplygithub.authentication import profile

my_profile = profile.write_profile(name="default",
                                   repo="jtpaasch/simplygithub",
                                   token="a3ef21ac0f...")

That will save the profile in a file at ~/.profile/simplygithub/github. (You can also create/modify this file yourself, by hand.)

You can load the profile anytime later with the read_profile() function:

from simplygithub.authentication import profile

my_profile = profile.read_profile("default")

Once you have a profile loaded into a variable (like my_profile), you can use it for any of the Simply Github functions that requires a profile as their first argument.

Creating branches

Use the simplygithub.branches package to work with branches:

from simplygithub import branches

To see a list of all your branches (using my_profile from above):

branches.list_branches(my_profile)

To create a branch off of master:

branches.create_branch(my_profile, "feature-branch", branch_off="master")

To merge a feature branch into master:

branches.merge(my_profile, "feature-branch", merge_into="master")

To delete a branch:

branches.delete_branch(my_profile, "feature-branch")

Adding and removing files from a branch

Use the simplygithub.files package to work with files:

from simplygithub import files

To list all file objects in a branch (using my_profile from above):

files.list_files(my_profile, "feature-branch")

To get the (UTF-8 encoded) contents of a file on a branch:

files.get_file(my_profile,
               branch="feature-branch",
               file_path="folder/path/foo.py")

To add a file to a branch:

files.add_file(my_profile,
               branch="feature-branch",
               file_path="folder/path/foo.py",
               file_contents="This is a silly file.")

That will add a file at folder/path/foo.py, and give it the contents This is a silly file.. It will commit that into the feature-branch.

If the file is an executable, add is_executable=True as a parameter. If you want to provide a commit message, you do that with the commit_message parameter:

files.add_file(my_profile,
               branch="feature-branch",
               file_path="folder/path/foo.py",
               file_contents="This is a silly file.",
               is_executable=True,
               commit_message="Added a silly file.")

To delete a file from a branch:

files.remove_file(my_profile,
                  branch="feature-branch",
                  file_path="folder/path/foo.py")

That will remove the file from the branch and commit the change. You can add an optional commit_message parameter if you like:

files.remove_file(my_profile,
                  branch="feature-branch",
                  file_path="folder/path/foo.py",
                  commit_message="Removed a silly file.")

Metadata

Release files for simplygithub 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simplygithub 0.2.0
File Size Uploaded Provenance Actions
simplygithub-0.2.0.tar.gz 9.9 kB Without provenance Details for simplygithub-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for simplygithub 0.2.0
File Interpreter ABI Platform Actions
simplygithub-0.2.0-py2.py3-none-any.whl Python 2, Python 3 none any Details for simplygithub-0.2.0-py2.py3-none-any.whl

Total release size: 26.2 kB

Release files / simplygithub-0.2.0.tar.gz

Download URL simplygithub-0.2.0.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
775dd7568374b5dd717c817db14f0fb86eb4e44737aa87f516c863373cfe2201
BLAKE2b-256 checksum
How to use checksums
500ad21b70ac58861166e34fb0ad3e42e32d89ff07709f76acae23415cfa9c09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / simplygithub-0.2.0-py2.py3-none-any.whl

Download URL simplygithub-0.2.0-py2.py3-none-any.whl
Size 16.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
389b33bb275421b744cad7c231b119f155e31b47ee667c09dc1c74ea239c6e9e
BLAKE2b-256 checksum
How to use checksums
a8d43db997bc54d191f0bd06b7c7e9443a8167b54ae5d3abd178c252df586e96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for simplygithub 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page