Skip to content

Commit 22346fc

Browse files
committed
feat(workspace): add workspace capabilities with Python package configuration
- Implemented fork method to create Git worktree with branch management - Added commit method for staging and committing changes to repository - Removed abstract base class inheritance and LLM usage dependencies - Integrated Rust backend functions for Git operations via PyO3 - Created pyproject.toml with proper package metadata and build configuration - Added Python package structure with maturin build system integration - Configured dependency management with fabricatio-core as required dependency
1 parent a71a166 commit 22346fc

File tree

5 files changed

+24
-12
lines changed

5 files changed

+24
-12
lines changed

packages/fabricatio-workspace/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "fabricatio-workspace"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
description = "An extension of fabricatio"
55
readme = "README.md"
66
license = "MIT"
Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
"""This module contains the capabilities for the workspace."""
22

3-
from abc import ABC
3+
from pathlib import Path
4+
from typing import List
45

5-
from fabricatio_core.capabilities.usages import UseLLM
6+
from fabricatio_workspace.rust import commit, fork
67

78

8-
class Workspace(UseLLM, ABC):
9+
class Workspace:
910
"""This class contains the capabilities for the workspace."""
1011

11-
async def workspace(self, **kwargs) -> None:
12-
"""Todo"""
12+
def fork(
13+
self,
14+
repo_path: str | Path,
15+
to: str | Path,
16+
branch_name: str,
17+
base_branch: str | None = None,
18+
exist_ok: bool = False,
19+
) -> Path:
20+
"""Fork a worktree."""
21+
return fork(repo_path, to, branch_name, base_branch, exist_ok)
22+
23+
def commit(self, repo_path: str | Path, msg: str, files: None | List[str]) -> str:
24+
"""Commit staged changes."""
25+
return commit(repo_path, msg, files)

packages/fabricatio-workspace/python/fabricatio_workspace/models/workspace.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/fabricatio-workspace/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg_attr(feature = "stubgen", allow(dead_code, unused, ))]
1+
#![cfg_attr(feature = "stubgen", allow(dead_code, unused,))]
22

33
use pyo3::prelude::*;
44
#[cfg(feature = "stubgen")]

packages/fabricatio-workspace/src/workspace.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use pyo3::prelude::*;
77
use pyo3_stub_gen::derive::*;
88
use std::path::PathBuf;
99

10-
1110
/// Forks a new Git worktree with safety checks and automatic cleanup.
1211
///
1312
/// This function creates a new worktree linked to a specific branch. It handles
@@ -92,8 +91,8 @@ pub fn fork(
9291
.into_pyresult()?,
9392
false,
9493
)
95-
.into_pyresult()?
96-
.into_reference()
94+
.into_pyresult()?
95+
.into_reference()
9796
} else {
9897
return Err(PyRuntimeError::new_err(format!(
9998
"Branch `{branch_name}` already exists, can't create other one with the same name!"
@@ -223,7 +222,8 @@ pub fn commit(worktree_path: PathBuf, msg: &str, files: Option<Vec<String>>) ->
223222

224223
// 2. Stage files
225224
if let Some(file_list) = files {
226-
if file_list.is_empty() {} else {
225+
if file_list.is_empty() {
226+
} else {
227227
for file in file_list {
228228
index
229229
.add_path(std::path::Path::new(&file))

0 commit comments

Comments
 (0)