git_well.git_track_upstream module¶
- Requirements:
pip install GitPython
- class git_well.git_track_upstream.TrackUpstreamCLI(*args: Any, **kwargs: Any)[source]¶
Bases:
DataConfigSet 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(argv: list[str] | str | bool | None = True, **kwargs: Any) None[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') >>> argv = False >>> cls = TrackUpstreamCLI >>> kwargs = cls() >>> kwargs['repo_dpath'] = repo >>> cls.main(argv=argv, **kwargs)
- default = {'force': <Value(False)>, 'repo_dpath': <Value('.')>}¶
- git_well.git_track_upstream.unique_remotes_with_branch(repo: Any, branch: Any) list[dict[str, Any]][source]¶
- git_well.git_track_upstream.main(argv: list[str] | str | bool | None = True, **kwargs: Any) None¶
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') >>> argv = False >>> cls = TrackUpstreamCLI >>> kwargs = cls() >>> kwargs['repo_dpath'] = repo >>> cls.main(argv=argv, **kwargs)