Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions asyncgit/src/asyncjob/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ mod test {
let res =
self.v.fetch_add(self.value_to_add, Ordering::SeqCst);

println!("[job] value: {}", res);
println!("[job] value: {res}");

Ok(())
}
Expand Down Expand Up @@ -236,8 +236,8 @@ mod test {
}

println!("recv");
let _foo = receiver.recv().unwrap();
let _foo = receiver.recv().unwrap();
receiver.recv().unwrap();
receiver.recv().unwrap();
assert!(receiver.is_empty());

assert_eq!(
Expand Down Expand Up @@ -282,7 +282,7 @@ mod test {
wait_for_job(&job);

println!("recv");
let _foo = receiver.recv().unwrap();
receiver.recv().unwrap();
println!("received");

assert_eq!(
Expand Down
4 changes: 2 additions & 2 deletions asyncgit/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ pub type Result<T> = std::result::Result<T, Error>;

impl<T> From<std::sync::PoisonError<T>> for Error {
fn from(error: std::sync::PoisonError<T>) -> Self {
Self::Generic(format!("poison error: {}", error))
Self::Generic(format!("poison error: {error}"))
}
}

impl<T> From<crossbeam_channel::SendError<T>> for Error {
fn from(error: crossbeam_channel::SendError<T>) -> Self {
Self::Generic(format!("send error: {}", error))
Self::Generic(format!("send error: {error}"))
}
}
15 changes: 6 additions & 9 deletions asyncgit/src/sync/blame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,18 +170,15 @@ mod tests {
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

assert!(matches!(
blame_file(&repo_path, "foo", None),
Err(_)
));
assert!(matches!(blame_file(repo_path, "foo", None), Err(_)));

File::create(&root.join(file_path))?
.write_all(b"line 1\n")?;

stage_add_file(repo_path, file_path)?;
commit(repo_path, "first commit")?;

let blame = blame_file(&repo_path, "foo", None)?;
let blame = blame_file(repo_path, "foo", None)?;

assert!(matches!(
blame.lines.as_slice(),
Expand All @@ -205,7 +202,7 @@ mod tests {
stage_add_file(repo_path, file_path)?;
commit(repo_path, "second commit")?;

let blame = blame_file(&repo_path, "foo", None)?;
let blame = blame_file(repo_path, "foo", None)?;

assert!(matches!(
blame.lines.as_slice(),
Expand All @@ -232,14 +229,14 @@ mod tests {

file.write(b"line 3\n")?;

let blame = blame_file(&repo_path, "foo", None)?;
let blame = blame_file(repo_path, "foo", None)?;

assert_eq!(blame.lines.len(), 2);

stage_add_file(repo_path, file_path)?;
commit(repo_path, "third commit")?;

let blame = blame_file(&repo_path, "foo", None)?;
let blame = blame_file(repo_path, "foo", None)?;

assert_eq!(blame.lines.len(), 3);

Expand All @@ -264,6 +261,6 @@ mod tests {
stage_add_file(repo_path, file_path).unwrap();
commit(repo_path, "first commit").unwrap();

assert!(blame_file(&repo_path, "bar\\foo", None).is_ok());
assert!(blame_file(repo_path, "bar\\foo", None).is_ok());
}
}
4 changes: 2 additions & 2 deletions asyncgit/src/sync/branch/merge_commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ mod test {
false,
false,
None,
None.into(),
None,
)
.is_err());

Expand Down Expand Up @@ -195,7 +195,7 @@ mod test {
//verify commit msg
let details = crate::sync::get_commit_details(
&clone2_dir.into(),
merge_commit.into(),
merge_commit,
)
.unwrap();
assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion asyncgit/src/sync/branch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ pub(crate) fn branch_set_upstream(

if branch.upstream().is_err() {
let remote = get_default_remote_in_repo(repo)?;
let upstream_name = format!("{}/{}", remote, branch_name);
let upstream_name = format!("{remote}/{branch_name}");
branch.set_upstream(Some(upstream_name.as_str()))?;
}

Expand Down
6 changes: 3 additions & 3 deletions asyncgit/src/sync/branch/rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn rename_branch(

#[cfg(test)]
mod test {
use super::super::*;
use super::super::{checkout_branch, create_branch, RepoPath};
use super::rename_branch;
use crate::sync::tests::repo_init;

Expand All @@ -42,7 +42,7 @@ mod test {
assert_eq!(
repo.branches(None)
.unwrap()
.nth(0)
.next()
.unwrap()
.unwrap()
.0
Expand All @@ -58,7 +58,7 @@ mod test {
assert_eq!(
repo.branches(None)
.unwrap()
.nth(0)
.next()
.unwrap()
.unwrap()
.0
Expand Down
2 changes: 1 addition & 1 deletion asyncgit/src/sync/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ mod tests {

fn count_commits(repo: &Repository, max: usize) -> usize {
let mut items = Vec::new();
let mut walk = LogWalker::new(&repo, max).unwrap();
let mut walk = LogWalker::new(repo, max).unwrap();
walk.read(&mut items).unwrap();
items.len()
}
Expand Down
4 changes: 3 additions & 1 deletion asyncgit/src/sync/commit_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl CommitMessage {
///
pub fn combine(self) -> String {
if let Some(body) = self.body {
format!("{}\n{}", self.subject, body)
format!("{}\n{body}", self.subject)
} else {
self.subject
}
Expand All @@ -82,6 +82,8 @@ pub struct CommitDetails {

impl CommitDetails {
///
#[allow(clippy::missing_const_for_fn)]
// clippy doesn't realise indexing a String is not const
pub fn short_hash(&self) -> &str {
&self.hash[0..7]
}
Expand Down
7 changes: 3 additions & 4 deletions asyncgit/src/sync/commits_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ mod tests {
stage_add_file(repo_path, file_path).unwrap();
let c2 = commit(repo_path, "commit2").unwrap();

let res =
get_commits_info(repo_path, &vec![c2, c1], 50).unwrap();
let res = get_commits_info(repo_path, &[c2, c1], 50).unwrap();

assert_eq!(res.len(), 2);
assert_eq!(res[0].message.as_str(), "commit2");
Expand All @@ -187,7 +186,7 @@ mod tests {
stage_add_file(repo_path, file_path).unwrap();
let c1 = commit(repo_path, "subject\nbody").unwrap();

let res = get_commits_info(repo_path, &vec![c1], 50).unwrap();
let res = get_commits_info(repo_path, &[c1], 50).unwrap();

assert_eq!(res.len(), 1);
assert_eq!(res[0].message.as_str(), "subject");
Expand All @@ -211,7 +210,7 @@ mod tests {

let res = get_commits_info(
repo_path,
&vec![get_head_repo(&repo).unwrap().into()],
&[get_head_repo(&repo).unwrap()],
50,
)
.unwrap();
Expand Down
6 changes: 3 additions & 3 deletions asyncgit/src/sync/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl HookPaths {
} else {
let err = String::from_utf8_lossy(&output.stderr);
let out = String::from_utf8_lossy(&output.stdout);
let formatted = format!("{}{}", out, err);
let formatted = format!("{out}{err}");

Ok(HookResult::NotOk(formatted))
}
Expand Down Expand Up @@ -324,7 +324,7 @@ exit 1
let workdir = TempDir::new().unwrap();
let git_root = git_root.into_path();
let repo_path = &RepoPath::Workdir {
gitdir: dbg!(git_root.to_path_buf()),
gitdir: dbg!(git_root),
workdir: dbg!(workdir.into_path()),
};

Expand Down Expand Up @@ -541,7 +541,7 @@ exit 1
let workdir = TempDir::new().unwrap();
let git_root = git_root.into_path();
let repo_path = &RepoPath::Workdir {
gitdir: dbg!(git_root.to_path_buf()),
gitdir: dbg!(git_root),
workdir: dbg!(workdir.path().to_path_buf()),
};

Expand Down
6 changes: 3 additions & 3 deletions asyncgit/src/sync/logwalker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ mod tests {
walk.read(&mut items).unwrap();

assert_eq!(items.len(), 1);
assert_eq!(items[0], oid2.into());
assert_eq!(items[0], oid2);

Ok(())
}
Expand Down Expand Up @@ -190,7 +190,7 @@ mod tests {
dbg!(&info);

assert_eq!(items.len(), 2);
assert_eq!(items[0], oid2.into());
assert_eq!(items[0], oid2);

let mut items = Vec::new();
walk.read(&mut items).unwrap();
Expand Down Expand Up @@ -235,7 +235,7 @@ mod tests {
walker.read(&mut items).unwrap();

assert_eq!(items.len(), 1);
assert_eq!(items[0], second_commit_id.into());
assert_eq!(items[0], second_commit_id);

let mut items = Vec::new();
walker.read(&mut items).unwrap();
Expand Down
18 changes: 9 additions & 9 deletions asyncgit/src/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ mod tests {
let temp_dir = TempDir::new().unwrap();
let path = temp_dir.path();

set_search_path(ConfigLevel::System, &path).unwrap();
set_search_path(ConfigLevel::Global, &path).unwrap();
set_search_path(ConfigLevel::XDG, &path).unwrap();
set_search_path(ConfigLevel::ProgramData, &path).unwrap();
set_search_path(ConfigLevel::System, path).unwrap();
set_search_path(ConfigLevel::Global, path).unwrap();
set_search_path(ConfigLevel::XDG, path).unwrap();
set_search_path(ConfigLevel::ProgramData, path).unwrap();
});
}

Expand Down Expand Up @@ -279,7 +279,7 @@ mod tests {
.try_init();
}

/// Same as repo_init, but the repo is a bare repo (--bare)
/// Same as `repo_init`, but the repo is a bare repo (--bare)
pub fn repo_init_bare() -> Result<(TempDir, Repository)> {
init_log();

Expand All @@ -303,7 +303,7 @@ mod tests {
///
pub fn debug_cmd_print(path: &RepoPath, cmd: &str) {
let cmd = debug_cmd(path, cmd);
eprintln!("\n----\n{}", cmd);
eprintln!("\n----\n{cmd}");
}

/// helper to fetch commmit details using log walker
Expand All @@ -323,7 +323,7 @@ mod tests {
fn debug_cmd(path: &RepoPath, cmd: &str) -> String {
let output = if cfg!(target_os = "windows") {
Command::new("cmd")
.args(&["/C", cmd])
.args(["/C", cmd])
.current_dir(path.gitpath())
.output()
.unwrap()
Expand All @@ -343,12 +343,12 @@ mod tests {
if stdout.is_empty() {
String::new()
} else {
format!("out:\n{}", stdout)
format!("out:\n{stdout}")
},
if stderr.is_empty() {
String::new()
} else {
format!("err:\n{}", stderr)
format!("err:\n{stderr}")
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion asyncgit/src/sync/rebase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ mod test_conflict_free_rebase {
.find_commit(c.into())
.unwrap()
.parent_ids()
.map(|id| CommitId::from(id))
.map(CommitId::from)
.collect();

foo
Expand Down
6 changes: 3 additions & 3 deletions asyncgit/src/sync/remotes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ mod tests {

debug_cmd_print(
repo_path,
&format!("git remote add second {}", remote_path)[..],
&format!("git remote add second {remote_path}")[..],
);

let remotes = get_remotes(repo_path).unwrap();
Expand Down Expand Up @@ -251,7 +251,7 @@ mod tests {

debug_cmd_print(
repo_path,
&format!("git remote add origin {}", remote_path)[..],
&format!("git remote add origin {remote_path}")[..],
);

//NOTE: aparently remotes are not chronolically sorted but alphabetically
Expand Down Expand Up @@ -287,7 +287,7 @@ mod tests {

debug_cmd_print(
repo_path,
&format!("git remote add someremote {}", remote_path)[..],
&format!("git remote add someremote {remote_path}")[..],
);

let remotes = get_remotes(repo_path).unwrap();
Expand Down
14 changes: 5 additions & 9 deletions asyncgit/src/sync/remotes/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ pub fn push_raw(
};

let branch_name =
format!("{}refs/{}/{}", branch_modifier, ref_type, branch);
format!("{branch_modifier}refs/{ref_type}/{branch}");
remote.push(&[branch_name.as_str()], Some(&mut options))?;

if let Some((reference, msg)) =
Expand Down Expand Up @@ -488,11 +488,9 @@ mod tests {
upstream_repo
.branches(None)
.unwrap()
.map(|i| i.unwrap())
.map(std::result::Result::unwrap)
.map(|(i, _)| i.name().unwrap().unwrap().to_string())
.filter(|i| i == "test_branch")
.next()
.is_some(),
.any(|i| &i == "test_branch"),
true
);

Expand All @@ -516,11 +514,9 @@ mod tests {
upstream_repo
.branches(None)
.unwrap()
.map(|i| i.unwrap())
.map(std::result::Result::unwrap)
.map(|(i, _)| i.name().unwrap().unwrap().to_string())
.filter(|i| i == "test_branch")
.next()
.is_some(),
.any(|i| &i == "test_branch"),
false
);
}
Expand Down
Loading