mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 08:58:21 +00:00
Fix ci (#2447)
This commit is contained in:
parent
809cb41668
commit
640bf333fc
23 changed files with 431 additions and 165 deletions
284
Cargo.lock
generated
284
Cargo.lock
generated
|
|
@ -698,6 +698,17 @@ dependencies = [
|
|||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "displaydoc"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dunce"
|
||||
version = "1.0.4"
|
||||
|
|
@ -1723,13 +1734,142 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "0.5.0"
|
||||
name = "icu_collections"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6"
|
||||
checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526"
|
||||
dependencies = [
|
||||
"unicode-bidi",
|
||||
"unicode-normalization",
|
||||
"displaydoc",
|
||||
"yoke",
|
||||
"zerofrom",
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "icu_locid"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"litemap",
|
||||
"tinystr",
|
||||
"writeable",
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "icu_locid_transform"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"icu_locid",
|
||||
"icu_locid_transform_data",
|
||||
"icu_provider",
|
||||
"tinystr",
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "icu_locid_transform_data"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e"
|
||||
|
||||
[[package]]
|
||||
name = "icu_normalizer"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"icu_collections",
|
||||
"icu_normalizer_data",
|
||||
"icu_properties",
|
||||
"icu_provider",
|
||||
"smallvec",
|
||||
"utf16_iter",
|
||||
"utf8_iter",
|
||||
"write16",
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "icu_normalizer_data"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516"
|
||||
|
||||
[[package]]
|
||||
name = "icu_properties"
|
||||
version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"icu_collections",
|
||||
"icu_locid_transform",
|
||||
"icu_properties_data",
|
||||
"icu_provider",
|
||||
"tinystr",
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "icu_properties_data"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569"
|
||||
|
||||
[[package]]
|
||||
name = "icu_provider"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"icu_locid",
|
||||
"icu_provider_macros",
|
||||
"stable_deref_trait",
|
||||
"tinystr",
|
||||
"writeable",
|
||||
"yoke",
|
||||
"zerofrom",
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "icu_provider_macros"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e"
|
||||
dependencies = [
|
||||
"idna_adapter",
|
||||
"smallvec",
|
||||
"utf8_iter",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "idna_adapter"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71"
|
||||
dependencies = [
|
||||
"icu_normalizer",
|
||||
"icu_properties",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1963,6 +2103,12 @@ version = "0.4.14"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
|
||||
|
||||
[[package]]
|
||||
name = "litemap"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.12"
|
||||
|
|
@ -2934,6 +3080,12 @@ dependencies = [
|
|||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stable_deref_trait"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||
|
||||
[[package]]
|
||||
name = "static_assertions"
|
||||
version = "1.1.0"
|
||||
|
|
@ -3005,6 +3157,17 @@ dependencies = [
|
|||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "synstructure"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syntect"
|
||||
version = "5.2.0"
|
||||
|
|
@ -3110,6 +3273,16 @@ dependencies = [
|
|||
"time-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinystr"
|
||||
version = "0.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f"
|
||||
dependencies = [
|
||||
"displaydoc",
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec"
|
||||
version = "1.8.0"
|
||||
|
|
@ -3162,12 +3335,6 @@ dependencies = [
|
|||
"arrayvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bom"
|
||||
version = "2.0.3"
|
||||
|
|
@ -3230,15 +3397,27 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "url"
|
||||
version = "2.5.2"
|
||||
version = "2.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c"
|
||||
checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60"
|
||||
dependencies = [
|
||||
"form_urlencoded",
|
||||
"idna",
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "utf16_iter"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246"
|
||||
|
||||
[[package]]
|
||||
name = "utf8_iter"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.2"
|
||||
|
|
@ -3542,12 +3721,48 @@ version = "0.0.19"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904"
|
||||
|
||||
[[package]]
|
||||
name = "write16"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936"
|
||||
|
||||
[[package]]
|
||||
name = "writeable"
|
||||
version = "0.5.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51"
|
||||
|
||||
[[package]]
|
||||
name = "yansi"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049"
|
||||
|
||||
[[package]]
|
||||
name = "yoke"
|
||||
version = "0.7.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"stable_deref_trait",
|
||||
"yoke-derive",
|
||||
"zerofrom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "yoke-derive"
|
||||
version = "0.7.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.7.35"
|
||||
|
|
@ -3568,8 +3783,51 @@ dependencies = [
|
|||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerofrom"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e"
|
||||
dependencies = [
|
||||
"zerofrom-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerofrom-derive"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zeroize"
|
||||
version = "1.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"
|
||||
|
||||
[[package]]
|
||||
name = "zerovec"
|
||||
version = "0.10.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079"
|
||||
dependencies = [
|
||||
"yoke",
|
||||
"zerofrom",
|
||||
"zerovec-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerovec-derive"
|
||||
version = "0.10.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ pub fn branch_merge_upstream_fastforward(
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod test {
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::sync::{
|
||||
remotes::{fetch, push::push_branch},
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@ pub fn untracked_files_config(
|
|||
}
|
||||
|
||||
/// get string from config
|
||||
|
||||
pub fn get_config_string(
|
||||
repo_path: &RepoPath,
|
||||
key: &str,
|
||||
|
|
|
|||
|
|
@ -10,21 +10,21 @@ use std::{
|
|||
|
||||
struct TimeOrderedCommit<'a>(Commit<'a>);
|
||||
|
||||
impl<'a> Eq for TimeOrderedCommit<'a> {}
|
||||
impl Eq for TimeOrderedCommit<'_> {}
|
||||
|
||||
impl<'a> PartialEq for TimeOrderedCommit<'a> {
|
||||
impl PartialEq for TimeOrderedCommit<'_> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.0.time().eq(&other.0.time())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> PartialOrd for TimeOrderedCommit<'a> {
|
||||
impl PartialOrd for TimeOrderedCommit<'_> {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Ord for TimeOrderedCommit<'a> {
|
||||
impl Ord for TimeOrderedCommit<'_> {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
self.0.time().cmp(&other.0.time())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ pub use utils::{
|
|||
|
||||
pub use git2::ResetType;
|
||||
|
||||
/// test utils
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::{
|
||||
|
|
@ -125,104 +126,6 @@ pub mod tests {
|
|||
use std::{path::Path, process::Command};
|
||||
use tempfile::TempDir;
|
||||
|
||||
/// Calling `set_search_path` with an empty directory makes sure that there
|
||||
/// is no git config interfering with our tests (for example user-local
|
||||
/// `.gitconfig`).
|
||||
#[allow(unsafe_code)]
|
||||
fn sandbox_config_files() {
|
||||
use git2::{opts::set_search_path, ConfigLevel};
|
||||
use std::sync::Once;
|
||||
|
||||
static INIT: Once = Once::new();
|
||||
|
||||
// Adapted from https://github.com/rust-lang/cargo/pull/9035
|
||||
INIT.call_once(|| unsafe {
|
||||
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();
|
||||
});
|
||||
}
|
||||
|
||||
/// write, stage and commit a file
|
||||
pub fn write_commit_file(
|
||||
repo: &Repository,
|
||||
file: &str,
|
||||
content: &str,
|
||||
commit_name: &str,
|
||||
) -> CommitId {
|
||||
repo_write_file(repo, file, content).unwrap();
|
||||
|
||||
stage_add_file(
|
||||
&repo.workdir().unwrap().to_str().unwrap().into(),
|
||||
Path::new(file),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
commit(
|
||||
&repo.workdir().unwrap().to_str().unwrap().into(),
|
||||
commit_name,
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
/// write, stage and commit a file giving the commit a specific timestamp
|
||||
pub fn write_commit_file_at(
|
||||
repo: &Repository,
|
||||
file: &str,
|
||||
content: &str,
|
||||
commit_name: &str,
|
||||
time: git2::Time,
|
||||
) -> CommitId {
|
||||
repo_write_file(repo, file, content).unwrap();
|
||||
|
||||
let path: &RepoPath =
|
||||
&repo.workdir().unwrap().to_str().unwrap().into();
|
||||
|
||||
stage_add_file(path, Path::new(file)).unwrap();
|
||||
|
||||
commit_at(path, commit_name, time)
|
||||
}
|
||||
|
||||
fn commit_at(
|
||||
repo_path: &RepoPath,
|
||||
msg: &str,
|
||||
time: git2::Time,
|
||||
) -> CommitId {
|
||||
let repo = repo(repo_path).unwrap();
|
||||
|
||||
let signature =
|
||||
git2::Signature::new("name", "email", &time).unwrap();
|
||||
let mut index = repo.index().unwrap();
|
||||
let tree_id = index.write_tree().unwrap();
|
||||
let tree = repo.find_tree(tree_id).unwrap();
|
||||
|
||||
let parents = if let Ok(id) = get_head_repo(&repo) {
|
||||
vec![repo.find_commit(id.into()).unwrap()]
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
|
||||
let parents = parents.iter().collect::<Vec<_>>();
|
||||
|
||||
let commit = repo
|
||||
.commit(
|
||||
Some("HEAD"),
|
||||
&signature,
|
||||
&signature,
|
||||
msg,
|
||||
&tree,
|
||||
parents.as_slice(),
|
||||
)
|
||||
.unwrap()
|
||||
.into();
|
||||
|
||||
commit
|
||||
}
|
||||
|
||||
///
|
||||
pub fn repo_init_empty() -> Result<(TempDir, Repository)> {
|
||||
init_log();
|
||||
|
|
@ -286,21 +189,44 @@ pub mod tests {
|
|||
Ok((td, repo))
|
||||
}
|
||||
|
||||
// init log
|
||||
fn init_log() {
|
||||
let _ = env_logger::builder()
|
||||
.is_test(true)
|
||||
.filter_level(log::LevelFilter::Trace)
|
||||
.try_init();
|
||||
/// write, stage and commit a file
|
||||
pub fn write_commit_file(
|
||||
repo: &Repository,
|
||||
file: &str,
|
||||
content: &str,
|
||||
commit_name: &str,
|
||||
) -> CommitId {
|
||||
repo_write_file(repo, file, content).unwrap();
|
||||
|
||||
stage_add_file(
|
||||
&repo.workdir().unwrap().to_str().unwrap().into(),
|
||||
Path::new(file),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
commit(
|
||||
&repo.workdir().unwrap().to_str().unwrap().into(),
|
||||
commit_name,
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
/// Same as `repo_init`, but the repo is a bare repo (--bare)
|
||||
pub fn repo_init_bare() -> Result<(TempDir, Repository)> {
|
||||
init_log();
|
||||
/// write, stage and commit a file giving the commit a specific timestamp
|
||||
pub fn write_commit_file_at(
|
||||
repo: &Repository,
|
||||
file: &str,
|
||||
content: &str,
|
||||
commit_name: &str,
|
||||
time: git2::Time,
|
||||
) -> CommitId {
|
||||
repo_write_file(repo, file, content).unwrap();
|
||||
|
||||
let tmp_repo_dir = TempDir::new()?;
|
||||
let bare_repo = Repository::init_bare(tmp_repo_dir.path())?;
|
||||
Ok((tmp_repo_dir, bare_repo))
|
||||
let path: &RepoPath =
|
||||
&repo.workdir().unwrap().to_str().unwrap().into();
|
||||
|
||||
stage_add_file(path, Path::new(file)).unwrap();
|
||||
|
||||
commit_at(path, commit_name, time)
|
||||
}
|
||||
|
||||
/// helper returning amount of files with changes in the (wd,stage)
|
||||
|
|
@ -335,6 +261,81 @@ pub mod tests {
|
|||
commit_ids
|
||||
}
|
||||
|
||||
/// Same as `repo_init`, but the repo is a bare repo (--bare)
|
||||
pub fn repo_init_bare() -> Result<(TempDir, Repository)> {
|
||||
init_log();
|
||||
|
||||
let tmp_repo_dir = TempDir::new()?;
|
||||
let bare_repo = Repository::init_bare(tmp_repo_dir.path())?;
|
||||
Ok((tmp_repo_dir, bare_repo))
|
||||
}
|
||||
|
||||
/// Calling `set_search_path` with an empty directory makes sure that there
|
||||
/// is no git config interfering with our tests (for example user-local
|
||||
/// `.gitconfig`).
|
||||
#[allow(unsafe_code)]
|
||||
fn sandbox_config_files() {
|
||||
use git2::{opts::set_search_path, ConfigLevel};
|
||||
use std::sync::Once;
|
||||
|
||||
static INIT: Once = Once::new();
|
||||
|
||||
// Adapted from https://github.com/rust-lang/cargo/pull/9035
|
||||
INIT.call_once(|| unsafe {
|
||||
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();
|
||||
});
|
||||
}
|
||||
|
||||
fn commit_at(
|
||||
repo_path: &RepoPath,
|
||||
msg: &str,
|
||||
time: git2::Time,
|
||||
) -> CommitId {
|
||||
let repo = repo(repo_path).unwrap();
|
||||
|
||||
let signature =
|
||||
git2::Signature::new("name", "email", &time).unwrap();
|
||||
let mut index = repo.index().unwrap();
|
||||
let tree_id = index.write_tree().unwrap();
|
||||
let tree = repo.find_tree(tree_id).unwrap();
|
||||
|
||||
let parents = if let Ok(id) = get_head_repo(&repo) {
|
||||
vec![repo.find_commit(id.into()).unwrap()]
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
|
||||
let parents = parents.iter().collect::<Vec<_>>();
|
||||
|
||||
let commit = repo
|
||||
.commit(
|
||||
Some("HEAD"),
|
||||
&signature,
|
||||
&signature,
|
||||
msg,
|
||||
&tree,
|
||||
parents.as_slice(),
|
||||
)
|
||||
.unwrap()
|
||||
.into();
|
||||
|
||||
commit
|
||||
}
|
||||
|
||||
// init log
|
||||
fn init_log() {
|
||||
let _ = env_logger::builder()
|
||||
.is_test(true)
|
||||
.filter_level(log::LevelFilter::Trace)
|
||||
.try_init();
|
||||
}
|
||||
|
||||
fn debug_cmd(path: &RepoPath, cmd: &str) -> String {
|
||||
let output = if cfg!(target_os = "windows") {
|
||||
Command::new("cmd")
|
||||
|
|
|
|||
|
|
@ -70,9 +70,11 @@ pub trait Sign {
|
|||
commit: &[u8],
|
||||
) -> Result<(String, Option<String>), SignError>;
|
||||
|
||||
/// only available in `#[cfg(test)]` helping to diagnose issues
|
||||
#[cfg(test)]
|
||||
fn program(&self) -> &String;
|
||||
|
||||
/// only available in `#[cfg(test)]` helping to diagnose issues
|
||||
#[cfg(test)]
|
||||
fn signing_key(&self) -> &String;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ allow = [
|
|||
"CC0-1.0",
|
||||
"ISC",
|
||||
"MPL-2.0",
|
||||
"Unicode-3.0",
|
||||
]
|
||||
|
||||
[advisories]
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ impl FileTreeItems {
|
|||
}
|
||||
|
||||
self.update_visibility(
|
||||
&Some(full_path),
|
||||
Some(full_path).as_ref(),
|
||||
index + 1,
|
||||
false,
|
||||
);
|
||||
|
|
@ -275,7 +275,7 @@ impl FileTreeItems {
|
|||
|
||||
fn update_visibility(
|
||||
&mut self,
|
||||
prefix: &Option<PathBuf>,
|
||||
prefix: Option<&PathBuf>,
|
||||
start_idx: usize,
|
||||
set_defaults: bool,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ impl<'a> ScopeTimeLog<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Drop for ScopeTimeLog<'a> {
|
||||
impl Drop for ScopeTimeLog<'_> {
|
||||
fn drop(&mut self) {
|
||||
log::trace!(
|
||||
"scopetime: {:?} ms [{}::{}] @{}:{}",
|
||||
|
|
|
|||
|
|
@ -102,11 +102,11 @@ impl DetailsComponent {
|
|||
}
|
||||
|
||||
fn get_wrapped_lines(
|
||||
data: &Option<CommitDetails>,
|
||||
data: Option<&CommitDetails>,
|
||||
width: usize,
|
||||
) -> WrappedCommitMessage<'_> {
|
||||
if let Some(ref data) = data {
|
||||
if let Some(ref message) = data.message {
|
||||
if let Some(data) = data {
|
||||
if let Some(message) = &data.message {
|
||||
return Self::wrap_commit_details(message, width);
|
||||
}
|
||||
}
|
||||
|
|
@ -115,7 +115,7 @@ impl DetailsComponent {
|
|||
}
|
||||
|
||||
fn get_number_of_lines(
|
||||
details: &Option<CommitDetails>,
|
||||
details: Option<&CommitDetails>,
|
||||
width: usize,
|
||||
) -> usize {
|
||||
let (wrapped_title, wrapped_message) =
|
||||
|
|
@ -138,7 +138,7 @@ impl DetailsComponent {
|
|||
height: usize,
|
||||
) -> Vec<Line> {
|
||||
let (wrapped_title, wrapped_message) =
|
||||
Self::get_wrapped_lines(&self.data, width);
|
||||
Self::get_wrapped_lines(self.data.as_ref(), width);
|
||||
|
||||
[&wrapped_title[..], &wrapped_message[..]]
|
||||
.concat()
|
||||
|
|
@ -286,8 +286,10 @@ impl DrawableComponent for DetailsComponent {
|
|||
|
||||
self.current_width.set(width);
|
||||
|
||||
let number_of_lines =
|
||||
Self::get_number_of_lines(&self.data, usize::from(width));
|
||||
let number_of_lines = Self::get_number_of_lines(
|
||||
self.data.as_ref(),
|
||||
usize::from(width),
|
||||
);
|
||||
|
||||
self.scroll.update_no_selection(
|
||||
number_of_lines,
|
||||
|
|
@ -340,7 +342,7 @@ impl Component for DetailsComponent {
|
|||
) -> CommandBlocking {
|
||||
let width = usize::from(self.current_width.get());
|
||||
let number_of_lines =
|
||||
Self::get_number_of_lines(&self.data, width);
|
||||
Self::get_number_of_lines(self.data.as_ref(), width);
|
||||
|
||||
out.push(
|
||||
CommandInfo::new(
|
||||
|
|
@ -488,13 +490,15 @@ mod test_line_count {
|
|||
..CommitDetails::default()
|
||||
};
|
||||
let lines = DetailsComponent::get_number_of_lines(
|
||||
&Some(commit.clone()),
|
||||
Some(commit.clone()).as_ref(),
|
||||
50,
|
||||
);
|
||||
assert_eq!(lines, 2);
|
||||
|
||||
let lines =
|
||||
DetailsComponent::get_number_of_lines(&Some(commit), 8);
|
||||
let lines = DetailsComponent::get_number_of_lines(
|
||||
Some(commit).as_ref(),
|
||||
8,
|
||||
);
|
||||
assert_eq!(lines, 4);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ impl CommitDetailsComponent {
|
|||
pub fn set_commits(
|
||||
&mut self,
|
||||
params: Option<CommitFilesParams>,
|
||||
tags: &Option<CommitTags>,
|
||||
tags: Option<&CommitTags>,
|
||||
) -> Result<()> {
|
||||
if params.is_none() {
|
||||
self.single_details.set_commit(None, None);
|
||||
|
|
@ -87,7 +87,7 @@ impl CommitDetailsComponent {
|
|||
}));
|
||||
} else {
|
||||
self.single_details
|
||||
.set_commit(Some(id.id), tags.clone());
|
||||
.set_commit(Some(id.id), tags.cloned());
|
||||
}
|
||||
|
||||
if let Some((fetched_id, res)) =
|
||||
|
|
|
|||
|
|
@ -761,7 +761,7 @@ impl CommitList {
|
|||
self.items.set_items(
|
||||
want_min,
|
||||
commits,
|
||||
&self.highlights,
|
||||
self.highlights.as_ref(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ impl ItemBatch {
|
|||
&mut self,
|
||||
start_index: usize,
|
||||
commits: Vec<CommitInfo>,
|
||||
highlighted: &Option<Rc<IndexSet<CommitId>>>,
|
||||
highlighted: Option<&Rc<IndexSet<CommitId>>>,
|
||||
) {
|
||||
self.clear();
|
||||
|
||||
|
|
|
|||
|
|
@ -544,7 +544,7 @@ impl BlameFilePopup {
|
|||
i,
|
||||
(blame_hunk.as_ref(), line.as_ref()),
|
||||
file_blame,
|
||||
&styled_text,
|
||||
styled_text.as_ref(),
|
||||
)
|
||||
})
|
||||
.collect()
|
||||
|
|
@ -585,7 +585,7 @@ impl BlameFilePopup {
|
|||
line_number: usize,
|
||||
hunk_and_line: (Option<&BlameHunk>, &str),
|
||||
file_blame: &'a SyntaxFileBlame,
|
||||
styled_text: &Option<Text<'a>>,
|
||||
styled_text: Option<&Text<'a>>,
|
||||
) -> Row<'a> {
|
||||
let (hunk_for_line, line) = hunk_and_line;
|
||||
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ impl CompareCommitsPopup {
|
|||
fn update(&mut self) -> Result<()> {
|
||||
self.details.set_commits(
|
||||
self.get_ids().map(CommitFilesParams::from),
|
||||
&None,
|
||||
None,
|
||||
)?;
|
||||
self.update_diff()?;
|
||||
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ impl FileRevlogPopup {
|
|||
);
|
||||
|
||||
if let Ok(commits) = commits {
|
||||
self.items.set_items(new_offset, commits, &None);
|
||||
self.items.set_items(new_offset, commits, None);
|
||||
}
|
||||
|
||||
self.count_total = git_log.count()?;
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ impl InspectCommitPopup {
|
|||
if let Some(request) = &self.open_request {
|
||||
self.details.set_commits(
|
||||
Some(request.commit_id.into()),
|
||||
&request.tags,
|
||||
request.tags.as_ref(),
|
||||
)?;
|
||||
self.update_diff()?;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ impl DrawableComponent for PullPopup {
|
|||
fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> {
|
||||
if self.visible {
|
||||
let (state, progress) =
|
||||
PushPopup::get_progress(&self.progress);
|
||||
PushPopup::get_progress(self.progress.as_ref());
|
||||
|
||||
let area = ui::centered_rect_absolute(30, 3, f.area());
|
||||
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ impl PushPopup {
|
|||
|
||||
///
|
||||
pub fn get_progress(
|
||||
progress: &Option<RemoteProgress>,
|
||||
progress: Option<&RemoteProgress>,
|
||||
) -> (String, u8) {
|
||||
progress.as_ref().map_or(
|
||||
(strings::PUSH_POPUP_PROGRESS_NONE.into(), 0),
|
||||
|
|
@ -232,7 +232,7 @@ impl DrawableComponent for PushPopup {
|
|||
fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> {
|
||||
if self.visible {
|
||||
let (state, progress) =
|
||||
Self::get_progress(&self.progress);
|
||||
Self::get_progress(self.progress.as_ref());
|
||||
|
||||
let area = ui::centered_rect_absolute(30, 3, f.area());
|
||||
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ impl PushTagsPopup {
|
|||
|
||||
///
|
||||
pub fn get_progress(
|
||||
progress: &Option<PushTagsProgress>,
|
||||
progress: Option<&PushTagsProgress>,
|
||||
) -> (String, u8) {
|
||||
progress.as_ref().map_or(
|
||||
(strings::PUSH_POPUP_PROGRESS_NONE.into(), 0),
|
||||
|
|
@ -160,7 +160,7 @@ impl DrawableComponent for PushTagsPopup {
|
|||
fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> {
|
||||
if self.visible {
|
||||
let (state, progress) =
|
||||
Self::get_progress(&self.progress);
|
||||
Self::get_progress(self.progress.as_ref());
|
||||
|
||||
let area = ui::centered_rect_absolute(30, 3, f.area());
|
||||
|
||||
|
|
|
|||
|
|
@ -138,11 +138,11 @@ impl Revlog {
|
|||
|
||||
if self.commit_details.is_visible() {
|
||||
let commit = self.selected_commit();
|
||||
let tags = self.selected_commit_tags(&commit);
|
||||
let tags = self.selected_commit_tags(commit.as_ref());
|
||||
|
||||
self.commit_details.set_commits(
|
||||
commit.map(CommitFilesParams::from),
|
||||
&tags,
|
||||
tags.as_ref(),
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
|
@ -206,12 +206,12 @@ impl Revlog {
|
|||
|
||||
fn selected_commit_tags(
|
||||
&self,
|
||||
commit: &Option<CommitId>,
|
||||
commit: Option<&CommitId>,
|
||||
) -> Option<CommitTags> {
|
||||
let tags = self.list.tags();
|
||||
|
||||
commit.and_then(|commit| {
|
||||
tags.and_then(|tags| tags.get(&commit).cloned())
|
||||
tags.and_then(|tags| tags.get(commit).cloned())
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -231,7 +231,8 @@ impl Revlog {
|
|||
|
||||
fn inspect_commit(&self) {
|
||||
if let Some(commit_id) = self.selected_commit() {
|
||||
let tags = self.selected_commit_tags(&Some(commit_id));
|
||||
let tags =
|
||||
self.selected_commit_tags(Some(commit_id).as_ref());
|
||||
self.queue.push(InternalEvent::OpenPopup(
|
||||
StackablePopupOpen::InspectCommit(
|
||||
InspectCommitOpen::new_with_tags(commit_id, tags),
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ impl<'a, 'b> WordWrapper<'a, 'b> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b> LineComposer<'a> for WordWrapper<'a, 'b> {
|
||||
impl<'a> LineComposer<'a> for WordWrapper<'a, '_> {
|
||||
fn next_line(&mut self) -> Option<(&[StyledGrapheme<'a>], u16)> {
|
||||
if self.max_line_width == 0 {
|
||||
return None;
|
||||
|
|
@ -166,7 +166,7 @@ impl<'a, 'b> LineTruncator<'a, 'b> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b> LineComposer<'a> for LineTruncator<'a, 'b> {
|
||||
impl<'a> LineComposer<'a> for LineTruncator<'a, '_> {
|
||||
fn next_line(&mut self) -> Option<(&[StyledGrapheme<'a>], u16)> {
|
||||
if self.max_line_width == 0 {
|
||||
return None;
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ impl<'a> StatefulParagraph<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> StatefulWidget for StatefulParagraph<'a> {
|
||||
impl StatefulWidget for StatefulParagraph<'_> {
|
||||
type State = ParagraphState;
|
||||
|
||||
fn render(
|
||||
|
|
|
|||
Loading…
Reference in a new issue