gittools.py¶
Wrap some git commands for use in programmatic revision control.
Originally developed for samplemap.py, so it has limited functionality dictated by that program’s limited use cases.
Generalized because I know I would like to use it eventually in syqada.
-
gittools.clean_environment(terms=['GIT_OBJECT_DIRECTORY', 'GIT_DIR'])[source]¶ Make sure that the user running this doesn’t have these two environment variables set (a different list may be expunged by providing a list of terms upon invocation).
-
gittools.git_commit(message, gitdir, all=False)[source]¶ Commit all added files, using message as the commit message.
Return True upon success, False upon failure.
gitdir is the path to the repository
-
gittools.git_fileadd(file, gitdir)[source]¶ git add a file for later commit.
Return True upon success, False upon failure.
gitdir is the path to the repository
-
gittools.git_filecommit(file, message, gitdir, already_controlled=True)[source]¶ Add and commit a single file, using message as the commit message.
Return True upon success, False upon failure.
if already_controlled is true, fail if the file is not already under version control in the repository. Default True on the assumption that this library is mostly about tight control of a few well-known objects.
gitdir is the path to the repository
-
gittools.git_filestatus(file, gitdir)[source]¶ Test the status of a file.
Return one of CLEAN, UNTRACKED, MODIFIED, ADDED, INVALID
Statuses of INVALID print error messages to sys.stderr
if file is None, return the whole result of git status
gitdir is the path to the repository
-
gittools.git_init(gitdir)[source]¶ Create and initialize a repository at path location gitdir
Return True upon success, False upon failure.
Fail complaining if gitdir exists.