angreal.python_bindings.integrations.git Binding¶
Git integration bindings
Classes¶
angreal.python_bindings.integrations.git.GitException¶
Rust Implementation: angreal::python_bindings::integrations::git::GitException
Methods¶
new¶
new(message: str) -> Self
Rust Implementation: angreal::python_bindings::integrations::git::GitException::new
__str__¶
__str__() -> str
Rust Implementation: angreal::python_bindings::integrations::git::GitException::str
angreal.python_bindings.integrations.git.Git¶
Rust Implementation: angreal::python_bindings::integrations::git::PyGit
Methods¶
new¶
new(working_dir: Optional[str]) -> Self
Rust Implementation: angreal::python_bindings::integrations::git::PyGit::new
Source
execute¶
execute(subcommand: str, args: List[str]) -> Tuple[int, Any, Any]
Rust Implementation: angreal::python_bindings::integrations::git::PyGit::execute
Source
fn execute(
&self,
subcommand: &str,
args: Vec<String>,
) -> PyResult<(i32, Py<PyAny>, Py<PyAny>)> {
Python::attach(|py| {
let arg_refs: Vec<&str> = args.iter().map(|s| s.as_str()).collect();
let output = self
.inner
.execute(subcommand, &arg_refs)
.map_err(|e| PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(e.to_string()))?;
Ok((
output.exit_code,
pyo3::types::PyBytes::new(py, output.stderr.as_bytes()).into(),
pyo3::types::PyBytes::new(py, output.stdout.as_bytes()).into(),
))
})
}
init¶
init(bare: Optional[bool]) -> Tuple[int, Any, Any]
Rust Implementation: angreal::python_bindings::integrations::git::PyGit::init
Source
fn init(&self, bare: Option<bool>) -> PyResult<(i32, Py<PyAny>, Py<PyAny>)> {
Python::attach(|py| {
let output = if bare.unwrap_or(false) {
self.inner.execute("init", &["--bare"])
} else {
self.inner.execute("init", &[])
}
.map_err(|e| PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(e.to_string()))?;
Ok((
output.exit_code,
pyo3::types::PyBytes::new(py, output.stderr.as_bytes()).into(),
pyo3::types::PyBytes::new(py, output.stdout.as_bytes()).into(),
))
})
}
add¶
add(paths: tuple) -> Tuple[int, Any, Any]
Rust Implementation: angreal::python_bindings::integrations::git::PyGit::add
Source
fn add(
&self,
paths: &Bound<'_, pyo3::types::PyTuple>,
) -> PyResult<(i32, Py<PyAny>, Py<PyAny>)> {
Python::attach(|py| {
let path_strs: Vec<String> = paths
.iter()
.map(|p| p.extract::<String>())
.collect::<Result<Vec<_>, _>>()?;
let path_refs: Vec<&str> = path_strs.iter().map(|s| s.as_str()).collect();
let output = self
.inner
.execute("add", &path_refs)
.map_err(|e| PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(e.to_string()))?;
Ok((
output.exit_code,
pyo3::types::PyBytes::new(py, output.stderr.as_bytes()).into(),
pyo3::types::PyBytes::new(py, output.stdout.as_bytes()).into(),
))
})
}
commit¶
commit(message: str, all: Optional[bool]) -> Tuple[int, Any, Any]
Rust Implementation: angreal::python_bindings::integrations::git::PyGit::commit
Source
fn commit(&self, message: &str, all: Option<bool>) -> PyResult<(i32, Py<PyAny>, Py<PyAny>)> {
Python::attach(|py| {
let args = if all.unwrap_or(false) {
vec!["-m", message, "-a"]
} else {
vec!["-m", message]
};
let output = self
.inner
.execute("commit", &args)
.map_err(|e| PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(e.to_string()))?;
Ok((
output.exit_code,
pyo3::types::PyBytes::new(py, output.stderr.as_bytes()).into(),
pyo3::types::PyBytes::new(py, output.stdout.as_bytes()).into(),
))
})
}
push¶
push(remote: Optional[str], branch: Optional[str]) -> Tuple[int, Any, Any]
Rust Implementation: angreal::python_bindings::integrations::git::PyGit::push
Source
fn push(
&self,
remote: Option<&str>,
branch: Option<&str>,
) -> PyResult<(i32, Py<PyAny>, Py<PyAny>)> {
Python::attach(|py| {
let mut args = vec![];
if let Some(r) = remote {
args.push(r);
}
if let Some(b) = branch {
args.push(b);
}
let output = self
.inner
.execute("push", &args)
.map_err(|e| PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(e.to_string()))?;
Ok((
output.exit_code,
pyo3::types::PyBytes::new(py, output.stderr.as_bytes()).into(),
pyo3::types::PyBytes::new(py, output.stdout.as_bytes()).into(),
))
})
}
pull¶
pull(remote: Optional[str], branch: Optional[str]) -> Tuple[int, Any, Any]
Rust Implementation: angreal::python_bindings::integrations::git::PyGit::pull
Source
fn pull(
&self,
remote: Option<&str>,
branch: Option<&str>,
) -> PyResult<(i32, Py<PyAny>, Py<PyAny>)> {
Python::attach(|py| {
let mut args = vec![];
if let Some(r) = remote {
args.push(r);
}
if let Some(b) = branch {
args.push(b);
}
let output = self
.inner
.execute("pull", &args)
.map_err(|e| PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(e.to_string()))?;
Ok((
output.exit_code,
pyo3::types::PyBytes::new(py, output.stderr.as_bytes()).into(),
pyo3::types::PyBytes::new(py, output.stdout.as_bytes()).into(),
))
})
}
status¶
status(short: Optional[bool]) -> Tuple[int, Any, Any]
Rust Implementation: angreal::python_bindings::integrations::git::PyGit::status
Source
fn status(&self, short: Option<bool>) -> PyResult<(i32, Py<PyAny>, Py<PyAny>)> {
Python::attach(|py| {
let args = if short.unwrap_or(false) {
vec!["--short"]
} else {
vec![]
};
let output = self
.inner
.execute("status", &args)
.map_err(|e| PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(e.to_string()))?;
Ok((
output.exit_code,
pyo3::types::PyBytes::new(py, output.stderr.as_bytes()).into(),
pyo3::types::PyBytes::new(py, output.stdout.as_bytes()).into(),
))
})
}
branch¶
branch(name: Optional[str], delete: Optional[bool]) -> Tuple[int, Any, Any]
Rust Implementation: angreal::python_bindings::integrations::git::PyGit::branch
Source
fn branch(
&self,
name: Option<&str>,
delete: Option<bool>,
) -> PyResult<(i32, Py<PyAny>, Py<PyAny>)> {
Python::attach(|py| {
let mut args = vec![];
if delete.unwrap_or(false) {
args.push("-d");
}
if let Some(n) = name {
args.push(n);
}
let output = self
.inner
.execute("branch", &args)
.map_err(|e| PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(e.to_string()))?;
Ok((
output.exit_code,
pyo3::types::PyBytes::new(py, output.stderr.as_bytes()).into(),
pyo3::types::PyBytes::new(py, output.stdout.as_bytes()).into(),
))
})
}
checkout¶
checkout(branch: str, create: Optional[bool]) -> Tuple[int, Any, Any]
Rust Implementation: angreal::python_bindings::integrations::git::PyGit::checkout
Source
fn checkout(
&self,
branch: &str,
create: Option<bool>,
) -> PyResult<(i32, Py<PyAny>, Py<PyAny>)> {
Python::attach(|py| {
let args = if create.unwrap_or(false) {
vec!["-b", branch]
} else {
vec![branch]
};
let output = self
.inner
.execute("checkout", &args)
.map_err(|e| PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(e.to_string()))?;
Ok((
output.exit_code,
pyo3::types::PyBytes::new(py, output.stderr.as_bytes()).into(),
pyo3::types::PyBytes::new(py, output.stdout.as_bytes()).into(),
))
})
}
tag¶
tag(name: str, message: Optional[str]) -> Tuple[int, Any, Any]
Rust Implementation: angreal::python_bindings::integrations::git::PyGit::tag
Source
fn tag(&self, name: &str, message: Option<&str>) -> PyResult<(i32, Py<PyAny>, Py<PyAny>)> {
Python::attach(|py| {
let args = if let Some(msg) = message {
vec!["-m", msg, name]
} else {
vec![name]
};
let output = self
.inner
.execute("tag", &args)
.map_err(|e| PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(e.to_string()))?;
Ok((
output.exit_code,
pyo3::types::PyBytes::new(py, output.stderr.as_bytes()).into(),
pyo3::types::PyBytes::new(py, output.stdout.as_bytes()).into(),
))
})
}
__call__¶
__call__(command: str, args: tuple, kwargs: Optional[dict]) -> Tuple[int, Any, Any]
Rust Implementation: angreal::python_bindings::integrations::git::PyGit::call
Source
fn __call__(
&self,
command: &str,
args: &Bound<'_, pyo3::types::PyTuple>,
kwargs: Option<&Bound<'_, PyDict>>,
) -> PyResult<(i32, Py<PyAny>, Py<PyAny>)> {
Python::attach(|py| {
// Convert args to Vec<String>
let arg_strs: Vec<String> = args
.iter()
.map(|p| p.extract::<String>())
.collect::<Result<Vec<_>, _>>()?;
let arg_refs: Vec<&str> = arg_strs.iter().map(|s| s.as_str()).collect();
let output = if let Some(dict) = kwargs {
// Convert PyDict to HashMap<String, String>
let mut options_owned = HashMap::new();
for (key, value) in dict.iter() {
let key_str = key.extract::<String>()?;
let value_str = if value.is_truthy()? {
"".to_string() // For boolean flags like --bare
} else {
value.extract::<String>()?
};
options_owned.insert(key_str, value_str);
}
// Convert to HashMap<&str, &str> for execute_with_options
let options: HashMap<&str, &str> = options_owned
.iter()
.map(|(k, v)| (k.as_str(), v.as_str()))
.collect();
self.inner.execute_with_options(command, options, &arg_refs)
} else {
self.inner.execute(command, &arg_refs)
}
.map_err(|e| {
// Check if this is an unsupported command error and convert to GitException
if e.to_string().contains("not supported") {
PyErr::new::<GitException, _>(e.to_string())
} else {
PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(e.to_string())
}
})?;
Ok((
output.exit_code,
pyo3::types::PyBytes::new(py, output.stderr.as_bytes()).into(),
pyo3::types::PyBytes::new(py, output.stdout.as_bytes()).into(),
))
})
}
working_dir¶
working_dir() -> str
Rust Implementation: angreal::python_bindings::integrations::git::PyGit::working_dir
__getattr__¶
__getattr__(_py: Python, name: str) -> Any
Rust Implementation: angreal::python_bindings::integrations::git::PyGit::getattr
Source
Functions¶
angreal.python_bindings.integrations.git.git_clone¶
git_clone(remote: str, destination: Optional[str]) -> str
Rust Implementation: angreal::git_clone