Make changelog author more concise
If both author name and email are present for a commit, format as a link. If one is absent, format as the other. If both are absent, format as "Anonymous". type: documentation
This commit is contained in:
parent
8ca2765259
commit
2d226cf016
6
.github/workflows/build.yaml
vendored
6
.github/workflows/build.yaml
vendored
|
@ -49,19 +49,19 @@ jobs:
|
||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ~/.cargo/registry
|
path: ~/.cargo/registry
|
||||||
key: v0-${{ runner.os }}-cargo-registry
|
key: v1-${{ runner.os }}-cargo-registry
|
||||||
|
|
||||||
- name: Cache cargo index
|
- name: Cache cargo index
|
||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ~/.cargo/git
|
path: ~/.cargo/git
|
||||||
key: v0-${{ runner.os }}-cargo-index
|
key: v1-${{ runner.os }}-cargo-index
|
||||||
|
|
||||||
- name: Cache cargo build
|
- name: Cache cargo build
|
||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: target
|
path: target
|
||||||
key: v0-${{ runner.os }}-cargo-build-target
|
key: v1-${{ runner.os }}-cargo-build-target
|
||||||
|
|
||||||
- name: Install Stable
|
- name: Install Stable
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
|
|
|
@ -24,13 +24,32 @@ impl Entry {
|
||||||
Metadata::from_commit(commit)?
|
Metadata::from_commit(commit)?
|
||||||
};
|
};
|
||||||
|
|
||||||
|
fn bytes_to_option(bytes: &[u8]) -> Option<String> {
|
||||||
|
let string = String::from_utf8_lossy(bytes).into_owned();
|
||||||
|
if string.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(string)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let name = bytes_to_option(commit.author().name_bytes());
|
||||||
|
let email = bytes_to_option(commit.author().email_bytes());
|
||||||
|
|
||||||
|
let author = match (name, email) {
|
||||||
|
(Some(name), Some(email)) => format!("[{}](mailto:{})", name, email),
|
||||||
|
(Some(name), None) => name,
|
||||||
|
(None, Some(email)) => email,
|
||||||
|
(None, None) => String::from("Anonymous"),
|
||||||
|
};
|
||||||
|
|
||||||
Entry {
|
Entry {
|
||||||
version: version.into(),
|
|
||||||
summary: commit.summary().unwrap().into(),
|
|
||||||
author: commit.author().to_string(),
|
|
||||||
hash: commit.id().to_string(),
|
hash: commit.id().to_string(),
|
||||||
metadata,
|
summary: commit.summary().unwrap().into(),
|
||||||
|
version: version.into(),
|
||||||
|
author,
|
||||||
head,
|
head,
|
||||||
|
metadata,
|
||||||
time,
|
time,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user