gitws.workspace module

Workspace Handling.

The Workspace class represents the location containing all git clones. Info is a helper.

class gitws.workspace.Info(*, main_path: Optional[Path] = None, filerefs: List[WorkspaceFileRef] = None)[source]

Bases: BaseModel

Workspace Information Container.

The workspace information container assembles all information which has to be kept persistent between tool invocations.

Keyword Arguments:

main_path – Path to main project. Relative to workspace root directory.

filerefs: List[WorkspaceFileRef]

File References.

These copied files and symbolic links have been created by GitWS and will be removed if not needed anymore.

static load(path: Path) Info[source]

Load Workspace Information from GitWS root directory at path.

The workspace information is stored at {path}/.gitws/info.toml.

Parameters:

path – Path to GitWS root directory.

main_path: Optional[Path]

Path to main project. Relative to workspace root directory.

model_config: ClassVar[ConfigDict] = {'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'filerefs': FieldInfo(annotation=List[gitws.datamodel.WorkspaceFileRef], required=False, default_factory=list), 'main_path': FieldInfo(annotation=Union[Path, NoneType], required=False)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

save(path: Path)[source]

Save Workspace Information at GitWS root directory at path.

The workspace information is stored at {path}/.gitws/info.toml.

Parameters:

path – Path to GitWS root directory.

class gitws.workspace.Workspace(path: Path, info: Info)[source]

Bases: object

Workspace.

The workspace contains all git clones, but is NOT a git clone itself. A workspace refers to a main git clone or a standalone manifest, which defines the workspace content (i.e. dependencies).

Parameters:
  • path – Workspace Root Directory.

  • info – Workspace Information.

property base_path: Path

Resolved Path To Main Project Or Workspace.

static check_empty(path: Path, main_path: Optional[Path])[source]

Check if Workspace at path with main_path is empty.

property config: AppConfigData

Application Configuration Values.

deinit()[source]

Deinitialize.

Remove GIT_WS_PATH directory.

edit_info() Iterator[Info][source]

Yield Contextmanager to edit Info and write back changes.

static find_path(path: Optional[Path] = None) Path[source]

Find Workspace Root Directory.

Keyword Arguments:

path (Path) – directory or file within the workspace. Current working directory by default.

Raises:

UninitializedError – If directory of file is not within a workspace.

The workspace root directory contains a sub directory .gitws. This one is searched upwards the given path.

static from_path(path=None) Workspace[source]

Create Workspace for existing workspace at path.

Keyword Arguments:

path (Path) – directory or file within the workspace. Current working directory by default.

Raises:

UninitializedError – If directory of file is not within a workspace.

The workspace root directory contains a sub directory .gitws. This one is searched upwards the given path.

get_group_filters(group_filters: Optional[Tuple[str, ...]] = None) Tuple[str, ...][source]

Get Group Filters.

Keyword Arguments:

group_filters – Group Filters.

The group filter is chosen according to the following list, the first matching wins:

  • Explicit group filter specified by group_filters.

  • Path from configuration (set during init, clone or later on).

  • empty group filters.

get_manifest_path(manifest_path: Optional[Path] = None) Path[source]

Get Resolved Manifest Path.

Keyword Arguments:

manifest_path – Absolute Or Relative (To self.base_path) Manifest Path.

The manifest path is chosen according to the following list, the first matching wins:

  • Explicit manifest path specified by manifest_path.

  • Path from configuration (set during init, clone or later on).

  • git-ws.toml (default)

get_project_path(project: Project, relative: bool = False) Path[source]

Determine Project Path.

Parameters:

project – Project to determine path for.

Keyword Arguments:

relative – Return relative instead of absolute path.

static init(path: Path, main_path: Optional[Path] = None, manifest_path: Optional[Path] = None, group_filters: Optional[Tuple[str, ...]] = None, depth: Optional[int] = None, force: bool = False) Workspace[source]

Initialize new Workspace at path.

Parameters:

path – Path to the workspace

Keyword Arguments:
  • main_path – Path to the main project. Relative to path.

  • manifest_path – Path to the manifest file. Relative to main_path or path. Default is git-ws.toml.

  • group_filters – Group Filters.

  • depth – Shallow Clone Depth.

  • force – Ignore that the workspace exists.

Raises:
static is_init(path: Path) Optional[Info][source]

Return Info if workspace is already initialized.

property main_path: Optional[Path]

Resolved Path To Main Project.