| 1 | //! Interact with git credentials in various ways and launch helper programs. |
| 2 | //! |
| 3 | //! ## Feature Flags |
| 4 | #![cfg_attr( |
| 5 | all(doc, feature = "document-features"), |
| 6 | doc = ::document_features::document_features!() |
| 7 | )] |
| 8 | #![cfg_attr(all(doc, feature = "document-features"), feature(doc_cfg))] |
| 9 | #![deny(missing_docs, rust_2018_idioms)] |
| 10 | #![forbid(unsafe_code)] |
| 11 | |
| 12 | /// A program/executable implementing the credential helper protocol. |
| 13 | #[derive(Debug)] |
| 14 | pub struct Program { |
| 15 | /// The kind of program, ready for launch. |
| 16 | pub kind: program::Kind, |
| 17 | /// If true, stderr is enabled, which is the default. |
| 18 | pub stderr: bool, |
| 19 | /// `Some(…)` if the process is running. |
| 20 | child: Option<std::process::Child>, |
| 21 | } |
| 22 | |
| 23 | /// |
| 24 | pub mod helper; |
| 25 | |
| 26 | /// |
| 27 | pub mod program; |
| 28 | |
| 29 | /// |
| 30 | pub mod protocol; |
| 31 | |
| 32 | /// Call the `git credential` helper program performing the given `action`, which reads all context from the git configuration |
| 33 | /// and does everything `git` typically does. The `action` should have been created with [`helper::Action::get_for_url()`] to |
| 34 | /// contain only the URL to kick off the process, or should be created by [`helper::NextAction`]. |
| 35 | /// |
| 36 | /// If more control is required, use the [`Cascade`][helper::Cascade] type. |
| 37 | #[allow(clippy::result_large_err)] |
| 38 | pub fn builtin(action: helper::Action) -> protocol::Result { |
| 39 | protocol::helper_outcome_to_result( |
| 40 | helper::invoke(&mut Program::from_kind(program::Kind::Builtin), &action)?, |
| 41 | action, |
| 42 | ) |
| 43 | } |