A git binary installed through PyPI for AWS Lambda - inspired by the JavaScript package lambda-git.
$ pip install lambda-git
To use this, just require it and call exec_command
. E.g:
import git
git.exec_command('init') # will run 'git init'
AWS Lambda give you only /tmp
as working directory. This package by default will execute all commands in /tmp
, but it can be overridden by passing cwd
.
import git
new_repo_path = '/tmp/my-new-repo'
os.mkdir(new_repo_path)
git.exec_command('init', cwd=new_repo_path)
By default every git command will be executed with the system environment, but it can be overridden by setting env
.
import git
commit_env = os.environ
commit_env['GIT_AUTHOR_NAME'] = 'My Name'
commit_env['GIT_AUTHOR_EMAIL'] = '[email protected]'
commit_env['GIT_COMMITTER_NAME'] = 'My Name'
commit_env['GIT_COMMITTER_EMAIL'] = '[email protected]'
new_repo_path = '/tmp/my-new-repo'
git.exec_command('add', '.', cwd=new_repo_path)
git.exec_command('commit', '-m "first commit"', cwd=new_repo_path, env=commit_env)
$ python -m nose
This repository is open to contributions.