git_well.git_sync module¶
- class git_well.git_sync.GitSyncCLI(*args, **kwargs)[source]¶
Bases:
DataConfig
Sync a git repo with a remote server via ssh
Valid options: []
- Parameters:
*args – positional arguments for this data config
**kwargs – keyword arguments for this data config
- default = {'dry': <Value(False)>, 'force': <Value(False)>, 'forward_ssh_agent': <Value(False)>, 'host': <Value(None)>, 'message': <Value('wip [skip ci]')>, 'remote': <Value(None)>}¶
- main(**kwargs)¶
- git_well.git_sync.getcwd()[source]¶
Workaround to get the working directory without dereferencing symlinks. This may not work on all systems.
References
https://stackoverflow.com/questions/1542803/getcwd-dereference-symlinks
- git_well.git_sync._devcheck()[source]¶
TODO: need to resolve the receive.denyCurrentBranch problem less manually
remote: error: refusing to update checked out branch: refs/heads/updates remote: error: By default, updating the current branch in a non-bare repository remote: is denied, because it will make the index and work tree inconsistent remote: with what you pushed, and will require ‘git reset –hard’ to match remote: the work tree to HEAD.
On the remote:
git config –local receive.denyCurrentBranch warn
- git_well.git_sync.git_sync(host, remote=None, message='wip [skip ci]', forward_ssh_agent=False, dry=False, force=False, home=None)[source]¶
Commit any changes in the current working directory, ssh into a remote machine, and then pull those changes.
- Parameters:
host (str) – The name of the host to sync to: e.g. user@remote.com
remote (str) – The git remote used to push and pull from
message (str, default=’wip [skip ci]’) – Default git commit message.
forward_ssh_agent (bool) – Enable forwarding of the ssh authentication agent connection
force (bool, default=False) – if True does a forced push and additionally forces the remote to do a hard reset to the remote state.
dry (bool, default=False) – Executes dry run mode.
home (str | PathLike | None) – if specified, overwrite where git-sync thinks the home location is
Example
>>> # xdoctest: +IGNORE_WANT >>> host = 'user@remote.com' >>> remote = 'origin' >>> message = 'this is the commit message' >>> home = getcwd() # pretend the home is here for the test >>> git_sync(host, remote, message, dry=True, home=home) git commit -am "this is the commit message" git push origin ssh user@remote.com "cd ... && git pull origin ..."