Radish alpha
r
Git libraries for Radicle
Radicle
Git (anonymous pull)
Log in to clone via SSH
radicle-surf: add short_name methods
Fintan Halpenny committed 3 years ago
commit 9f1302649c1bb5a6b179c150bc79af5beccbae5d
parent 1ac99ac456a74a66b5996b4bfd01f3f3f70dd8c8
2 files changed +39 -7
modified radicle-surf/src/git/branch.rs
@@ -37,6 +37,18 @@ impl Branch {
        Self::Remote(Remote::new(remote, name))
    }

+
    /// Return the short `Branch` refname,
+
    /// e.g. `fix/ref-format`.
+
    pub fn short_name(&self) -> &RefString {
+
        match self {
+
            Branch::Local(local) => local.short_name(),
+
            Branch::Remote(remote) => remote.short_name(),
+
        }
+
    }
+

+
    /// Give back the fully qualified `Branch` refname,
+
    /// e.g. `refs/remotes/origin/fix/ref-format`,
+
    /// `refs/heads/fix/ref-format`.
    pub fn refname(&self) -> Qualified {
        match self {
            Branch::Local(local) => local.refname(),
@@ -126,6 +138,12 @@ impl Local {
        }
    }

+
    /// Return the short `Local` refname,
+
    /// e.g. `fix/ref-format`.
+
    pub fn short_name(&self) -> &RefString {
+
        &self.name
+
    }
+

    /// Return the fully qualified `Local` refname,
    /// e.g. `refs/heads/fix/ref-format`.
    pub fn refname(&self) -> Qualified {
@@ -219,6 +237,18 @@ impl Remote {
        })
    }

+
    /// Return the short `Remote` refname,
+
    /// e.g. `fix/ref-format`.
+
    pub fn short_name(&self) -> &RefString {
+
        &self.name
+
    }
+

+
    /// Return the remote of the `Remote`'s refname,
+
    /// e.g. `origin`.
+
    pub fn remote(&self) -> &RefString {
+
        &self.remote
+
    }
+

    /// Give back the fully qualified `Remote` refname,
    /// e.g. `refs/remotes/origin/fix/ref-format`.
    pub fn refname(&self) -> Qualified {
modified radicle-surf/src/git/tag.rs
@@ -39,18 +39,20 @@ impl Tag {
        }
    }

-
    /// Return the fully qualified `Tag` refname,
-
    /// e.g. `refs/tags/release/v1`.
-
    pub fn refname(&self) -> Qualified {
-
        lit::refs_tags(self.name()).into()
-
    }
-

-
    fn name(&self) -> &RefString {
+
    /// Return the short `Tag` refname,
+
    /// e.g. `release/v1`.
+
    pub fn short_name(&self) -> &RefString {
        match &self {
            Tag::Light { name, .. } => name,
            Tag::Annotated { name, .. } => name,
        }
    }
+

+
    /// Return the fully qualified `Tag` refname,
+
    /// e.g. `refs/tags/release/v1`.
+
    pub fn refname(&self) -> Qualified {
+
        lit::refs_tags(self.short_name()).into()
+
    }
}

pub mod error {