This commit is contained in:
@@ -204,7 +204,7 @@ fn get_commits_since_version(
|
||||
}
|
||||
}
|
||||
|
||||
return Ok(commits);
|
||||
Ok(commits)
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -242,7 +242,7 @@ fn format_entry(
|
||||
maintainer_name, maintainer_email, date
|
||||
));
|
||||
|
||||
return entry;
|
||||
entry
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
38
src/get.rs
38
src/get.rs
@@ -72,10 +72,10 @@ fn clone_repo(
|
||||
builder.branch(b);
|
||||
}
|
||||
|
||||
return match builder.clone(url, &target_path) {
|
||||
match builder.clone(url, &target_path) {
|
||||
Ok(_repo) => Ok(()),
|
||||
Err(e) => Err(format!("Failed to clone: {}", e).into()),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
use sha2::{Digest, Sha256};
|
||||
@@ -109,7 +109,7 @@ fn extract_archive(path: &Path, dest: &Path) -> Result<(), Box<dyn Error>> {
|
||||
fn checkout_pristine_tar(package_dir: &Path, filename: &str) -> Result<(), Box<dyn Error>> {
|
||||
let output = Command::new("pristine-tar")
|
||||
.current_dir(package_dir)
|
||||
.args(&["checkout", format!("../{filename}").as_str()])
|
||||
.args(["checkout", format!("../{filename}").as_str()])
|
||||
.output()
|
||||
.expect("pristine-tar checkout failed");
|
||||
|
||||
@@ -154,7 +154,7 @@ async fn download_file_checksum(
|
||||
hasher.update(&chunk);
|
||||
|
||||
if let Some(cb) = progress {
|
||||
index = min(index + &chunk.len(), total_size as usize);
|
||||
index = min(index + chunk.len(), total_size as usize);
|
||||
cb("", "Downloading...", index, total_size as usize);
|
||||
}
|
||||
}
|
||||
@@ -188,21 +188,21 @@ fn setup_pristine_tar_branch(package_dir: &Path, dist: &str) -> Result<(), Box<d
|
||||
let branches = repo.branches(Some(git2::BranchType::Remote))?;
|
||||
for branch_result in branches {
|
||||
let (branch, _) = branch_result?;
|
||||
if let Some(name) = branch.name()? {
|
||||
if name.ends_with(&format!("/{dist}/pristine-tar")) {
|
||||
debug!("Found remote pristine-tar branch: {}", name);
|
||||
if let Some(name) = branch.name()?
|
||||
&& name.ends_with(&format!("/{dist}/pristine-tar"))
|
||||
{
|
||||
debug!("Found remote pristine-tar branch: {}", name);
|
||||
|
||||
let commit = branch.get().peel_to_commit()?;
|
||||
let commit = branch.get().peel_to_commit()?;
|
||||
|
||||
// Create local branch
|
||||
let mut local_branch = repo.branch("pristine-tar", &commit, false)?;
|
||||
// Create local branch
|
||||
let mut local_branch = repo.branch("pristine-tar", &commit, false)?;
|
||||
|
||||
// Set upstream
|
||||
local_branch.set_upstream(Some(name))?;
|
||||
// Set upstream
|
||||
local_branch.set_upstream(Some(name))?;
|
||||
|
||||
debug!("Created local pristine-tar branch tracking {}", name);
|
||||
return Ok(());
|
||||
}
|
||||
debug!("Created local pristine-tar branch tracking {}", name);
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,10 +287,10 @@ async fn fetch_archive_sources(
|
||||
let path = package_dir.join(&file.name);
|
||||
let extract_dir = package_dir.join(&info.stanza.package);
|
||||
|
||||
if file.name.ends_with(".tar.xz") || file.name.ends_with(".tar.gz") {
|
||||
if let Err(e) = extract_archive(&path, &extract_dir) {
|
||||
return Err(format!("Failed to extract {}: {}", file.name, e).into());
|
||||
}
|
||||
if (file.name.ends_with(".tar.xz") || file.name.ends_with(".tar.gz"))
|
||||
&& let Err(e) = extract_archive(&path, &extract_dir)
|
||||
{
|
||||
return Err(format!("Failed to extract {}: {}", file.name, e).into());
|
||||
}
|
||||
|
||||
// Remove archive after extraction
|
||||
|
||||
@@ -67,7 +67,7 @@ fn main() {
|
||||
.unwrap_or("");
|
||||
|
||||
// Since get is async, we need to block on it
|
||||
let (pb, mut progress_callback) = ui::create_progress_bar(&multi);
|
||||
let (pb, progress_callback) = ui::create_progress_bar(&multi);
|
||||
|
||||
if let Err(e) = rt.block_on(get(
|
||||
package,
|
||||
@@ -77,7 +77,7 @@ fn main() {
|
||||
ppa,
|
||||
dist,
|
||||
None,
|
||||
Some(&mut progress_callback),
|
||||
Some(&progress_callback),
|
||||
)) {
|
||||
pb.finish_and_clear();
|
||||
error!("{}", e);
|
||||
@@ -99,7 +99,7 @@ fn main() {
|
||||
let editor = std::env::var("EDITOR").unwrap();
|
||||
let _status = std::process::Command::new(editor)
|
||||
.current_dir(&cwd)
|
||||
.args(&["debian/changelog"])
|
||||
.args(["debian/changelog"])
|
||||
.status();
|
||||
}
|
||||
_ => unreachable!("Exhausted list of subcommands and subcommand_required prevents `None`"),
|
||||
|
||||
@@ -43,10 +43,10 @@ fn parse_series_csv(content: &str) -> Result<Vec<String>, Box<dyn Error>> {
|
||||
let mut entries = Vec::new();
|
||||
for result in rdr.records() {
|
||||
let record = result?;
|
||||
if let (Some(s), Some(c)) = (record.get(series_idx), record.get(created_idx)) {
|
||||
if let Ok(date) = NaiveDate::parse_from_str(c, "%Y-%m-%d") {
|
||||
entries.push((s.to_string(), date));
|
||||
}
|
||||
if let (Some(s), Some(c)) = (record.get(series_idx), record.get(created_idx))
|
||||
&& let Ok(date) = NaiveDate::parse_from_str(c, "%Y-%m-%d")
|
||||
{
|
||||
entries.push((s.to_string(), date));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,13 +186,13 @@ async fn get_components(
|
||||
let content = reqwest::get(&url).await?.text().await?;
|
||||
|
||||
for line in content.lines() {
|
||||
if line.starts_with("Components:") {
|
||||
if let Some((_, components)) = line.split_once(':') {
|
||||
return Ok(components
|
||||
.split_whitespace()
|
||||
.map(|s| s.to_string())
|
||||
.collect());
|
||||
}
|
||||
if line.starts_with("Components:")
|
||||
&& let Some((_, components)) = line.split_once(':')
|
||||
{
|
||||
return Ok(components
|
||||
.split_whitespace()
|
||||
.map(|s| s.to_string())
|
||||
.collect());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,42 +233,42 @@ fn parse_sources(
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(pkg) = fields.get("Package") {
|
||||
if pkg == target_package {
|
||||
// Check version if requested
|
||||
if let Some(ver) = target_version {
|
||||
if let Some(pkg_ver) = fields.get("Version") {
|
||||
if pkg_ver != ver {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if let Some(pkg) = fields.get("Package")
|
||||
&& pkg == target_package
|
||||
{
|
||||
// Check version if requested
|
||||
if let Some(ver) = target_version {
|
||||
if let Some(pkg_ver) = fields.get("Version") {
|
||||
if pkg_ver != ver {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
let mut files = Vec::new();
|
||||
if let Some(checksums) = fields.get("Checksums-Sha256") {
|
||||
for line in checksums.lines() {
|
||||
let parts: Vec<&str> = line.split_whitespace().collect();
|
||||
if parts.len() >= 3 {
|
||||
files.push(FileEntry {
|
||||
sha256: parts[0].to_string(),
|
||||
size: parts[1].parse().unwrap_or(0),
|
||||
name: parts[2].to_string(),
|
||||
});
|
||||
}
|
||||
let mut files = Vec::new();
|
||||
if let Some(checksums) = fields.get("Checksums-Sha256") {
|
||||
for line in checksums.lines() {
|
||||
let parts: Vec<&str> = line.split_whitespace().collect();
|
||||
if parts.len() >= 3 {
|
||||
files.push(FileEntry {
|
||||
sha256: parts[0].to_string(),
|
||||
size: parts[1].parse().unwrap_or(0),
|
||||
name: parts[2].to_string(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return Ok(Some(PackageStanza {
|
||||
package: pkg.clone(),
|
||||
version: fields.get("Version").cloned().unwrap_or_default(),
|
||||
directory: fields.get("Directory").cloned().unwrap_or_default(),
|
||||
vcs_git: fields.get("Vcs-Git").cloned(),
|
||||
vcs_browser: fields.get("Vcs-Browser").cloned(),
|
||||
files,
|
||||
}));
|
||||
}
|
||||
|
||||
return Ok(Some(PackageStanza {
|
||||
package: pkg.clone(),
|
||||
version: fields.get("Version").cloned().unwrap_or_default(),
|
||||
directory: fields.get("Directory").cloned().unwrap_or_default(),
|
||||
vcs_git: fields.get("Vcs-Git").cloned(),
|
||||
vcs_browser: fields.get("Vcs-Browser").cloned(),
|
||||
files,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,11 +286,11 @@ pub async fn get(
|
||||
// Handle Ubuntu case: Vcs-Git does not usually point to Launchpad but Salsa
|
||||
// We need to check manually if there is a launchpad repository for the package
|
||||
let mut preferred_vcs = None;
|
||||
if dist == "ubuntu" {
|
||||
if let Some(lp_url) = check_launchpad_repo(package_name).await? {
|
||||
debug!("Found Launchpad URL: {}", lp_url);
|
||||
preferred_vcs = Some(lp_url);
|
||||
}
|
||||
if dist == "ubuntu"
|
||||
&& let Some(lp_url) = check_launchpad_repo(package_name).await?
|
||||
{
|
||||
debug!("Found Launchpad URL: {}", lp_url);
|
||||
preferred_vcs = Some(lp_url);
|
||||
}
|
||||
|
||||
let base_url = get_base_url(&dist);
|
||||
@@ -324,19 +324,19 @@ pub async fn get(
|
||||
);
|
||||
|
||||
if let Some(stanza) = parse_sources(&compressed_data, package_name, version)? {
|
||||
if let Some(vcs) = &stanza.vcs_git {
|
||||
if preferred_vcs.is_none() {
|
||||
preferred_vcs = Some(vcs.clone());
|
||||
}
|
||||
if let Some(vcs) = &stanza.vcs_git
|
||||
&& preferred_vcs.is_none()
|
||||
{
|
||||
preferred_vcs = Some(vcs.clone());
|
||||
}
|
||||
|
||||
let archive_url = format!("{base_url}/{0}", stanza.directory);
|
||||
return Ok(PackageInfo {
|
||||
dist: dist,
|
||||
dist,
|
||||
series: series.to_string(),
|
||||
stanza: stanza,
|
||||
preferred_vcs: preferred_vcs,
|
||||
archive_url: archive_url,
|
||||
stanza,
|
||||
preferred_vcs,
|
||||
archive_url,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user