Skip to content

Commit 44178b0

Browse files
committed
support see-also
1 parent e905dc0 commit 44178b0

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

mdbook-goals/src/gh/issues.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ pub fn fetch_issue(repository: &Repository, issue: u64) -> anyhow::Result<Existi
122122
let output = Command::new("gh")
123123
.arg("-R")
124124
.arg(&repository.to_string())
125+
.arg("issue")
125126
.arg("view")
126127
.arg(&format!("{issue}"))
127128
.arg("--json")

mdbook-goals/src/json.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,13 @@ fn checkboxes(issue: &ExistingGithubIssue) -> anyhow::Result<Progress> {
150150
let issue_urls = c["issues"].split(&[',', ' ']).filter(|s| !s.is_empty());
151151

152152
for issue_url in issue_urls {
153-
let Some(c) = re::SEE_ALSO_ISSUE.captures(issue_url) else {
154-
anyhow::bail!("invalid issue URL `{issue_url}`")
153+
let c = match (
154+
re::SEE_ALSO_ISSUE1.captures(issue_url),
155+
re::SEE_ALSO_ISSUE2.captures(issue_url),
156+
) {
157+
(Some(c), _) => c,
158+
(None, Some(c)) => c,
159+
(None, None) => anyhow::bail!("invalid issue URL `{issue_url}`"),
155160
};
156161
let repository = Repository::new(&c["org"], &c["repo"]);
157162
let issue_number = c["issue"].parse::<u64>()?;

mdbook-goals/src/re.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,16 @@ lazy_static! {
4141

4242
lazy_static! {
4343
pub static ref SEE_ALSO_QUERY: Regex =
44-
Regex::new(r"^\| *See also *\| (?P<issues>[^, ]+,|[^, ] )+ *\| *$").unwrap();
44+
Regex::new(r"^\| *See also *\|(?P<issues>[^|]+)\| *$").unwrap();
4545
}
4646

4747
lazy_static! {
48-
pub static ref SEE_ALSO_ISSUE: Regex = Regex::new(r"(?P<org>[^#/]*)/(?P<repo>[^#/]*)#(?P<issue>[0-9]+)|https://github.com/(?P<org>[^#/]*)/(?P<repo>[^#/]*)/issues/(?P<issue>[0-9]+)").unwrap();
48+
pub static ref SEE_ALSO_ISSUE1: Regex =
49+
Regex::new(r"(?P<org>[^#/]*)/(?P<repo>[^#/]*)#(?P<issue>[0-9]+)").unwrap();
50+
}
51+
52+
lazy_static! {
53+
pub static ref SEE_ALSO_ISSUE2: Regex =
54+
Regex::new(r"https://github.com/(?P<org>[^#/]*)/(?P<repo>[^#/]*)/issues/(?P<issue>[0-9]+)")
55+
.unwrap();
4956
}

0 commit comments

Comments
 (0)