angreal::python_bindings::integrations::git
Rust
Git integration bindings
Structs
Section titled “Structs”class GitException
Section titled “class GitException”Binding
Python API:
angreal.integrations.git_integration.GitException
Fields
Section titled “Fields”| Name | Type | Description |
|---|---|---|
message |
String |
Methods
Section titled “Methods”fn new(message: String) -> SelfPython API:
angreal.integrations.git_integration.GitException.new
Source
fn new(message: String) -> Self { Self { message } }__str__
Section titled “__str__”fn __str__(&self) -> StringPython API:
angreal.integrations.git_integration.GitException.__str__
Source
fn __str__(&self) -> String { self.message.clone() }class Git
Section titled “class Git”Binding
Fields
Section titled “Fields”| Name | Type | Description |
|---|---|---|
inner |
Git |
Methods
Section titled “Methods”fn new(working_dir: Option<&str>) -> PyResult<Self>Source
fn new(working_dir: Option<&str>) -> PyResult<Self> { let git = Git::new(working_dir.map(Path::new)) .map_err(|e| PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(e.to_string()))?; Ok(Self { inner: git }) }execute
Section titled “execute”fn execute( &self, subcommand: &str, args: Vec<String>,) -> PyResult<(i32, Py<PyAny>, Py<PyAny>)>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(), )) }) }fn init( &self) -> PyResult<(i32, Py<PyAny>, Py<PyAny>, bare: Option<bool>) -> PyResult<(i32, Py<PyAny>, Py<PyAny>,) -> PyResult<(i32, Py<PyAny>, Py<PyAny>)>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(), )) }) }fn add( &self, paths: &Bound<'_, pyo3::types::PyTuple>,) -> PyResult<(i32, Py<PyAny>, Py<PyAny>)>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
Section titled “commit”fn commit( &self, message: &str, all: Option<bool>,) -> PyResult<(i32, Py<PyAny>, Py<PyAny>)>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(), )) }) }fn push( &self, remote: Option<&str>, branch: Option<&str>,) -> PyResult<(i32, Py<PyAny>, Py<PyAny>)>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(), )) }) }fn pull( &self, remote: Option<&str>, branch: Option<&str>,) -> PyResult<(i32, Py<PyAny>, Py<PyAny>)>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
Section titled “status”fn status( &self) -> PyResult<(i32, Py<PyAny>, Py<PyAny>, short: Option<bool>) -> PyResult<(i32, Py<PyAny>, Py<PyAny>,) -> PyResult<(i32, Py<PyAny>, Py<PyAny>)>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
Section titled “branch”fn branch( &self, name: Option<&str>, delete: Option<bool>,) -> PyResult<(i32, Py<PyAny>, Py<PyAny>)>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
Section titled “checkout”fn checkout( &self, branch: &str, create: Option<bool>,) -> PyResult<(i32, Py<PyAny>, Py<PyAny>)>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(), )) }) }fn tag( &self, name: &str, message: Option<&str>,) -> PyResult<(i32, Py<PyAny>, Py<PyAny>)>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__
Section titled “__call__”fn __call__( &self, command: &str, args: &Bound<'_, pyo3::types::PyTuple>, kwargs: Option<&Bound<'_, PyDict>>,) -> PyResult<(i32, Py<PyAny>, Py<PyAny>)>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
Section titled “working_dir”fn working_dir(&self) -> StringSource
fn working_dir(&self) -> String { self.inner.working_dir().display().to_string() }__getattr__
Section titled “__getattr__”fn __getattr__(&self, _py: Python, name: &str) -> PyResult<Py<PyAny>>Source
fn __getattr__(&self, _py: Python, name: &str) -> PyResult<Py<PyAny>> { // For any unknown method, raise GitException Err(PyErr::new::<GitException, _>(format!( "Git command '{}' not found", name ))) }Functions
Section titled “Functions”fn git_clone
Section titled “fn git_clone”Binding
fn git_clone( remote: &str, destination: Option<&str>,) -> PyResult<String>Source
pub fn git_clone(remote: &str, destination: Option<&str>) -> PyResult<String> { let dest = Git::clone(remote, destination.map(Path::new)) .map_err(|e| PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(e.to_string()))?; Ok(dest.display().to_string())}fn git_integration
Section titled “fn git_integration”pub
fn git_integration(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()>Git integration module
This will be exposed as angreal.integrations.git in Python
Source
pub fn git_integration(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::<GitException>()?; // Export PyGit as "Git" to match the expected interface m.add("Git", _py.get_type::<PyGit>())?; // Export git_clone as "clone" to match the expected interface m.add("clone", wrap_pyfunction!(git_clone, m)?)?; Ok(())}