git_well.repo module¶
- class git_well.repo.Repo(path: str | PathLike[str] | None = None, odbt: Type[LooseObjectDB] = <class 'git.db.GitCmdObjectDB'>, search_parent_directories: bool = False, expand_vars: bool = True)[source]¶
Bases:
RepoCreate a new
Repoinstance.- Parameters:
path –
The path to either the worktree directory or the .git directory itself:
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(R"C:\Users\mtrier\Development\git-python\.git")
In Cygwin, path may be a
cygdrive/...prefixed path.If path is
Noneor an empty string,GIT_DIRis used. If that environment variable is absent or empty, 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:
git.exc.InvalidGitRepositoryError –
git.exc.NoSuchPathError –
- Returns:
- cmd(command: str | list[str], **kwargs: Any) Any[source]¶
Execute a command in the root of the repo.
- classmethod coerce(data: str | PathLike[str] | Repo) Repo[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