git_well.git_track_upstream module

Requirements:

pip install GitPython

class git_well.git_track_upstream.TrackUpstreamCLI(*args, **kwargs)[source]

Bases: DataConfig

Set the branch upstream with sensible defaults if possible.

This script can auto-choose sensible default if there is only one remote that also has the working branch. When there is an ambiguity the user will be asked to choose from a list of available remotes with this branch.

Once the remote is found the script executes:

..code:: bash

git branch –set-upstream-to=<remote>/<branch> <branch>

Valid options: []

Parameters:
  • *args – positional arguments for this data config

  • **kwargs – keyword arguments for this data config

classmethod main(cmdline=1, **kwargs)[source]

Example

>>> from git_well.git_track_upstream import TrackUpstreamCLI
>>> from git_well.repo import Repo
>>> repo = Repo.demo()
>>> repo.cmd('git remote add origin https://github.com/Erotemic/git_well.git')
>>> # TODO: make this test work without the network
>>> repo.cmd('git fetch origin')
>>> repo.cmd('git reset --hard origin/main')
>>> cmdline = 0
>>> cls = TrackUpstreamCLI
>>> kwargs = cls()
>>> kwargs['repo_dpath'] = repo
>>> cls.main(cmdline=cmdline, **kwargs)
default = {'force': <Value(False)>, 'repo_dpath': <Value('.')>}
git_well.git_track_upstream.unique_remotes_with_branch(repo, branch)[source]
git_well.git_track_upstream.main(cmdline=1, **kwargs)

Example

>>> from git_well.git_track_upstream import TrackUpstreamCLI
>>> from git_well.repo import Repo
>>> repo = Repo.demo()
>>> repo.cmd('git remote add origin https://github.com/Erotemic/git_well.git')
>>> # TODO: make this test work without the network
>>> repo.cmd('git fetch origin')
>>> repo.cmd('git reset --hard origin/main')
>>> cmdline = 0
>>> cls = TrackUpstreamCLI
>>> kwargs = cls()
>>> kwargs['repo_dpath'] = repo
>>> cls.main(cmdline=cmdline, **kwargs)