foundry_dev_tools.utils.repo module

foundry_dev_tools.utils.repo module#

This file provides helper function for git repos.

foundry_dev_tools.utils.repo.get_repo(repo_dir=None)[source]#

Get the repository RID of the current working directory.

Parameters:

repo_dir (Path | None) – the path to a (sub)directory of a git repo, otherwise current working directory

Returns:

repo_rid,git_ref,git_revision_hash

Return type:

tuple[str,str,str]

foundry_dev_tools.utils.repo.get_git_ref(git_dir=None)[source]#

Get the branch ref in the supplied git directory.

Parameters:

git_dir (Path | None) – the path to a (sub)directory of a git repo, otherwise current working directory

Return type:

str

foundry_dev_tools.utils.repo.get_git_revision_hash(git_dir=None)[source]#

Get the git revision hash.

Parameters:

git_dir (Path | None) – the path to a (sub)directory of a git repo, otherwise current working directory

Return type:

str

foundry_dev_tools.utils.repo.git_toplevel_dir(git_dir=None, use_git=False)[source]#

Get git top level directory.

Parameters:
  • git_dir (Path | None) – the path to a (sub)directory of a git repo, otherwise current working directory

  • use_git (bool) – if true call git executable with subprocess, otherwise use minimal python only implementation

Returns:

the path to the toplevel git directory or

None if nothing was found.

Return type:

Path | None

foundry_dev_tools.utils.repo.get_branch(caller_filename)[source]#

Get name of current checked out git branch as defined in the git HEAD file.

Parameters:

caller_filename (Path) – Path of file that calls the function

Returns:

Name of checked out branch

Return type:

str