1#[must_use]
3pub fn new(name: &str) -> SymbolicRef<'_> {
4 SymbolicRef::new(name)
5}
6
7#[derive(Debug)]
13pub struct SymbolicRef<'a> {
14 base: crate::RepoBase<'a>,
15 name: &'a str,
16}
17
18crate::impl_repo_base!(SymbolicRef);
19
20impl<'a> SymbolicRef<'a> {
21 #[must_use]
22 fn new(name: &'a str) -> Self {
23 Self {
24 base: crate::RepoBase::default(),
25 name,
26 }
27 }
28}
29
30impl crate::Build for SymbolicRef<'_> {
31 fn build(self) -> Result<cmd_proc::Command, crate::EnvError> {
32 Ok(self
33 .base
34 .command()?
35 .argument("symbolic-ref")
36 .argument(self.name))
37 }
38}
39
40#[cfg(feature = "test-utils")]
41impl SymbolicRef<'_> {
42 pub fn test_eq(&self, other: &cmd_proc::Command) {
44 let command = crate::Build::build(Self {
45 base: self.base,
46 name: self.name,
47 })
48 .unwrap();
49 command.test_eq(other);
50 }
51}
52
53#[cfg(all(test, feature = "test-utils"))]
54mod tests {
55 use super::*;
56
57 #[test]
58 fn test_symbolic_ref_command() {
59 let expected = cmd_proc::Command::new("git")
60 .argument("symbolic-ref")
61 .argument("refs/remotes/origin/HEAD");
62
63 new("refs/remotes/origin/HEAD").test_eq(&expected);
64 }
65}