Skip to content

Commit

Permalink
Revert id -> short_id name change (#254)
Browse files Browse the repository at this point in the history
* Revert id -> short_id name change

* Update CHANGELOG
  • Loading branch information
Jake-Shadle authored Aug 12, 2024
1 parent 02d5831 commit f0ec54e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- next-header -->
## [Unreleased] - ReleaseDate
## [0.6.3] - 2024-08-12
### Fixed
- [PR#254](https://github.com/EmbarkStudios/cargo-about/pull/254) reverted unintended `id` -> `short_id` field rename.

## [0.6.3] **yanked** - 2024-08-12
### Changed
- [PR#251](https://github.com/EmbarkStudios/cargo-about/pull/251) updated crates and directly depend on `semver`.

Expand Down
6 changes: 3 additions & 3 deletions about.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<h2>Overview of licenses:</h2>
<ul class="licenses-overview">
{{#each overview}}
<li><a href="#{{short_id}}">{{name}}</a> ({{count}})</li>
<li><a href="#{{id}}">{{name}}</a> ({{count}})</li>
{{/each}}
</ul>

Expand All @@ -57,10 +57,10 @@
{{#each licenses}}
<!-- Write out a header for each block of the same license -->
{{#if first_of_kind}}
<h3 id="{{short_id}}">{{name}}</h3>
<h3 id="{{id}}">{{name}}</h3>
{{/if}}
<li class="license">
<h4 id="{{short_id}}-{{@index}}">{{name}}</h>
<h4 id="{{id}}-{{@index}}">{{name}}</h>
<h5>Used by:</h5>
<ul class="license-used-by">
{{#each used_by}}
Expand Down
14 changes: 7 additions & 7 deletions src/cargo-about/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ struct License<'a> {
/// The full name of the license
name: String,
/// The SPDX short identifier for the license
short_id: String,
id: String,
/// True if this is the first license of its kind in the flat array
first_of_kind: bool,
/// The full license text
Expand All @@ -300,7 +300,7 @@ struct License<'a> {
struct LicenseSet {
count: usize,
name: String,
short_id: String,
id: String,
indices: Vec<usize>,
text: String,
}
Expand Down Expand Up @@ -367,7 +367,7 @@ fn generate<'kl>(
| licenses::LicenseFileKind::AddendumText(text, _) => {
let license = License {
name: id.full_name.to_owned(),
short_id: id.name.to_owned(),
id: id.name.to_owned(),
text: text.clone(),
source_path: Some(lf.path.clone()),
used_by: Vec::new(),
Expand All @@ -389,7 +389,7 @@ fn generate<'kl>(
// fallback to the canonical license text and emit a warning
license_texts.push(License {
name: id.full_name.to_owned(),
short_id: id.name.to_owned(),
id: id.name.to_owned(),
text: id.text().to_owned(),
source_path: None,
used_by: Vec::new(),
Expand Down Expand Up @@ -431,7 +431,7 @@ fn generate<'kl>(
lic.used_by.sort_by(|a, b| a.krate.id.cmp(&b.krate.id));
}

licenses.sort_by(|a, b| a.short_id.cmp(&b.short_id));
licenses.sort_by(|a, b| a.id.cmp(&b.id));
licenses
};

Expand All @@ -444,7 +444,7 @@ fn generate<'kl>(
let mut overview: Vec<LicenseSet> = Vec::with_capacity(256);

for (ndx, lic) in licenses.iter_mut().enumerate() {
match overview.binary_search_by(|i| i.short_id.cmp(&lic.short_id)) {
match overview.binary_search_by(|i| i.id.cmp(&lic.id)) {
Ok(i) => {
let ov = &mut overview[i];
ov.indices.push(ndx);
Expand All @@ -454,7 +454,7 @@ fn generate<'kl>(
let mut ls = LicenseSet {
count: lic.used_by.len(),
name: lic.name.clone(),
short_id: lic.short_id.clone(),
id: lic.id.clone(),
indices: Vec::with_capacity(10),
text: lic.text.clone(),
};
Expand Down

0 comments on commit f0ec54e

Please sign in to comment.