Skip to content

Commit

Permalink
Always display the private ticket footnote; 24
Browse files Browse the repository at this point in the history
  • Loading branch information
msuchane committed Oct 27, 2023
1 parent fe56670 commit 1d8cf88
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
24 changes: 11 additions & 13 deletions src/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,32 +67,30 @@ impl AbstractTicket {
///
/// For example, `link:https://...bugzilla...12345[BZ#12345]`.
#[must_use]
pub fn signature(&self) -> String {
pub fn signature(&self, with_priv_footnote: bool) -> String {
let id = &self.id;

if self.public {
// If the ticket is public, add a clickable link.
format!("link:{}[{}]", &self.url, id)
} else {
// If the ticket is private, add a footnote that explains
// why some links aren't clickable.
// The shared ID of the private footnote is arbitrary and large to avoid clashes:
// 255 is the u8 max value.
// The `{private-footnote}` attribute is defined in the reference template,
// and the user can override it in their AsciiDoc files.
//
// TODO: This works with asciidoctor, but the footnote doesn't render
// at all with Pantheon. Disabling for now.
// format!("{id}{{fn-private}}")
id.to_string()
// If the ticket is private, and the project configures a dedicated footnote,
// add a footnote that explains why the link isn't clickable.
// This uses the deprecated AsciiDoc `footnoteref` syntax
// so that you can build the document with very outdated asciidoctor.
if with_priv_footnote {
format!("{id}footnoteref:[PrivateTicketFootnote]")
} else {
id.to_string()
}
}
}

/// Prepare a list with signatures to this ticket and all its optional references.
/// The result is a comma-separated list of signatures, enclosed in parentheses.
#[must_use]
fn all_signatures(&self) -> String {
let mut signatures = vec![self.signature()];
let mut signatures = vec![self.signature(true)];

if let Some(references) = self.references.as_ref() {
signatures.append(&mut references.clone());
Expand Down
6 changes: 4 additions & 2 deletions src/references.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ impl ReferenceSignatures {
let ticket = issue.into_abstract(None, config)?;
signatures
.entry(query)
.and_modify(|e| e.push(ticket.signature()))
.or_insert_with(|| vec![ticket.signature()]);
// In reference IDs, never display the private ticket footnote,
// even when it's defined in the project. Too much clutter on one line.
.and_modify(|e| e.push(ticket.signature(false)))
.or_insert_with(|| vec![ticket.signature(false)]);
}

Ok(())
Expand Down

0 comments on commit 1d8cf88

Please sign in to comment.