Skip to content

Commit

Permalink
trivial: linter doesn't require copyright banner
Browse files Browse the repository at this point in the history
Looks like Diem Contributors is now ambiguous.

Closes: aptos-labs#10167
  • Loading branch information
msmouse authored and bors-diem committed Feb 18, 2022
1 parent a7c8f77 commit cab87c9
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions devtools/x/src/lint/license.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0

use std::collections::HashSet;
use x_lint::prelude::*;

static LICENSE_HEADER: &str = "Copyright (c) The Diem Core Contributors\n\
static LICENSE_HEADER: &str = "\
SPDX-License-Identifier: Apache-2.0\n\
";

Expand Down Expand Up @@ -45,21 +46,29 @@ impl ContentLinter for LicenseHeader {
// Determine if the file is missing the license header
let missing_header = match file_type {
FileType::Rust | FileType::Proto => {
let maybe_license = content
let maybe_license: HashSet<_> = content
.lines()
.skip_while(|line| line.is_empty())
.take(2)
.map(|s| s.trim_start_matches("// "));
!LICENSE_HEADER.lines().eq(maybe_license)
.map(|s| s.trim_start_matches("// "))
.collect();
!LICENSE_HEADER
.lines()
.collect::<HashSet<_>>()
.is_subset(&maybe_license)
}
FileType::Shell => {
let maybe_license = content
.lines()
.skip_while(|line| line.starts_with("#!"))
.skip_while(|line| line.is_empty())
.take(2)
.map(|s| s.trim_start_matches("# "));
!LICENSE_HEADER.lines().eq(maybe_license)
.map(|s| s.trim_start_matches("# "))
.collect();
!LICENSE_HEADER
.lines()
.collect::<HashSet<_>>()
.is_subset(&maybe_license)
}
};

Expand Down

0 comments on commit cab87c9

Please sign in to comment.