Skip to main content

public_text

Function public_text 

Source
pub fn public_text(text: &str) -> String
Expand description

Free text as it may be shown and written down: every URL in it without its credentials.

For what this tool relays rather than composes — the standard error of a git or a gh that failed, which names the remote it could not reach in whatever form the remote was configured. That text is recorded in the integration trail, and the trail is served. Whether the subprocess anonymised its own message is a property of someone else’s tool at someone else’s version; this is the same rule as public_url, applied to each URL the text contains, and everything that is not a URL’s userinfo is left exactly as it was.

use majordomus_cli::session::public_text;
assert_eq!(
    public_text("fatal: unable to access 'https://user:secret@host/x/': timeout"),
    "fatal: unable to access 'https://host/x/': timeout"
);
assert_eq!(
    public_text("a https://t0ken@h/a and ssh://git:pw@h:22/b, then c"),
    "a https://h/a and ssh://git@h:22/b, then c"
);
// nothing to remove, nothing changed: no URL, a clean URL, an address in a sentence
for same in ["no url here", "see https://host/o/r@v1 now", "mail me@example.org", "a://", "://x@y"] {
    assert_eq!(public_text(same), same);
}