git_well.repo module

class git_well.repo.Repo(path: str | ~os.PathLike[str] | None = None, odbt: ~typing.Type[~gitdb.db.loose.LooseObjectDB] = <class 'git.db.GitCmdObjectDB'>, search_parent_directories: bool = False, expand_vars: bool = True)[source]

Bases: Repo

Create a new Repo instance.

Parameters:
  • path

    The path to either the root git directory or the bare git repo:

    repo = Repo("/Users/mtrier/Development/git-python")
    repo = Repo("/Users/mtrier/Development/git-python.git")
    repo = Repo("~/Development/git-python.git")
    repo = Repo("$REPOSITORIES/Development/git-python.git")
    repo = Repo("C:\Users\mtrier\Development\git-python\.git")
    
    • In Cygwin, path may be a cygdrive/... prefixed path.

    • If it evaluates to false, GIT_DIR is used, and if this also evals to false, the current-directory is used.

  • odbt – Object DataBase type - a type which is constructed by providing the directory containing the database objects, i.e. .git/objects. It will be used to access all object data

  • search_parent_directories

    If True, all parent directories will be searched for a valid repo as well.

    Please note that this was the default behaviour in older versions of GitPython, which is considered a bug though.

Raises:
  • InvalidGitRepositoryError

  • NoSuchPathError

Returns:

git.Repo

cmd(command, **kwargs)[source]

Execute a command in the root of the repo.

property dpath

Alias of working_dir wraped in a ubelt Path

property is_submodule

True if the submodule for another repo.

property config_fpath
classmethod coerce(data)[source]

Try to construct a Repo object from input dat

Parameters:

data (str | PathLike | Repo) – If a Repo object, data is returned as-is. If a path inside a git repo, return a Repo object that references the repo root.

Returns:

Repo

classmethod demo()[source]

Create a demo repo for tests

Returns:

Repo

Example

>>> from git_well.repo import Repo
>>> self = Repo.demo()
find_merged_branches(main_branch='main')[source]