copyright.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use crate::errors::{ Result }; use crate::git::{ CommitReference, Repository, RepositoryExtensions }; pub(crate) fn summarize(repository: &Repository, commit: &CommitReference) -> Result<String> { let mut license_file = None; for license_path in ["LICENSE.md", "license.md", "LICENSE.txt", "license.txt", "LICENSE", "license", "COPYING.md", "copying.md", "COPYING.txt", "copying.txt", "COPYING", "copying"] { if let Ok(_) = repository.find_blob_text_by_path(commit, license_path) { license_file = Some(license_path.to_string()); break; } } if let Some(license_file) = license_file { Ok(format!("This repository has a license in the {} file. Please read it and ensure you comply with its terms before using, sharing, or modifying these files.", license_file)) } else { Ok("This repository does not have a license file. As such, the author(s) reserve all rights to this content. Do not use, share, or modify these files without explicit permission.".to_string()) } }