aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/ba/back/src/git_bug
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/ba/back/src/git_bug')
-rw-r--r--pkgs/by-name/ba/back/src/git_bug/dag/mod.rs14
-rw-r--r--pkgs/by-name/ba/back/src/git_bug/format/mod.rs15
-rw-r--r--pkgs/by-name/ba/back/src/git_bug/issue/mod.rs2
3 files changed, 28 insertions, 3 deletions
diff --git a/pkgs/by-name/ba/back/src/git_bug/dag/mod.rs b/pkgs/by-name/ba/back/src/git_bug/dag/mod.rs
index 9c158a7..3d22b04 100644
--- a/pkgs/by-name/ba/back/src/git_bug/dag/mod.rs
+++ b/pkgs/by-name/ba/back/src/git_bug/dag/mod.rs
@@ -123,11 +123,23 @@ impl Dag {
}
}
+/// Check whether `git-bug` has been initialized in this repository
+pub fn is_git_bug(repo: &Repository) -> error::Result<bool> {
+ Ok(repo
+ .refs
+ .iter()?
+ .prefixed(Path::new("refs/bugs/"))
+ .map_err(|err| error::Error::RepoRefsPrefixed { error: err })?
+ .count()
+ > 0)
+}
+
pub fn issues_from_repository(repo: &Repository) -> error::Result<Vec<Dag>> {
let dags = repo
.refs
.iter()?
- .prefixed(Path::new("refs/bugs/"))?
+ .prefixed(Path::new("refs/bugs/"))
+ .map_err(|err| error::Error::RepoRefsPrefixed { error: err })?
.map(|val| {
let reference = val.expect("All `git-bug` references in 'refs/bugs' should be objects");
diff --git a/pkgs/by-name/ba/back/src/git_bug/format/mod.rs b/pkgs/by-name/ba/back/src/git_bug/format/mod.rs
index b3b6bcc..ffe44fd 100644
--- a/pkgs/by-name/ba/back/src/git_bug/format/mod.rs
+++ b/pkgs/by-name/ba/back/src/git_bug/format/mod.rs
@@ -16,8 +16,8 @@ use markdown::to_html;
use serde::Deserialize;
use serde_json::Value;
-#[derive(Debug, Default, Clone)]
/// Markdown content.
+#[derive(Debug, Default, Clone)]
pub struct MarkDown {
value: String,
}
@@ -88,6 +88,19 @@ pub struct HtmlString {
value: String,
}
+impl From<String> for HtmlString {
+ fn from(value: String) -> Self {
+ Self { value }
+ }
+}
+impl From<&str> for HtmlString {
+ fn from(value: &str) -> Self {
+ Self {
+ value: value.to_owned(),
+ }
+ }
+}
+
impl From<MarkDown> for HtmlString {
fn from(value: MarkDown) -> Self {
Self { value: value.value }
diff --git a/pkgs/by-name/ba/back/src/git_bug/issue/mod.rs b/pkgs/by-name/ba/back/src/git_bug/issue/mod.rs
index f27bfec..d382b54 100644
--- a/pkgs/by-name/ba/back/src/git_bug/issue/mod.rs
+++ b/pkgs/by-name/ba/back/src/git_bug/issue/mod.rs
@@ -128,7 +128,7 @@ impl RawCollapsedIssue {
} => {
self.id = Some(entity.id.clone());
self.author = Some(entity.author.clone());
- self.timestamp = Some(timestamp.clone());
+ self.timestamp = Some(timestamp);
self.title = Some(title);
self.message = Some(message);
self.status = Some(Status::Open); // This is the default in git_bug