forked from mirrors/jj
commit
6a2bb466ac
7 changed files with 62 additions and 3 deletions
29
.github/workflows/build.yml
vendored
Normal file
29
.github/workflows/build.yml
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
name: build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.operating-system }}
|
||||
strategy:
|
||||
matrix:
|
||||
operating-system: [ ubuntu-latest, windows-latest, macos-latest ]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install Rust nightly
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
override: true
|
||||
profile: minimal
|
||||
- name: Build
|
||||
run: |
|
||||
cargo build --workspace --verbose
|
||||
- name: Test
|
||||
run: |
|
||||
cargo test --workspace --verbose
|
|
@ -36,6 +36,9 @@ impl FileLock {
|
|||
Err(err) if err.kind() == std::io::ErrorKind::AlreadyExists => {
|
||||
Err(backoff::Error::Transient(err))
|
||||
}
|
||||
Err(err) if cfg!(windows) && err.kind() == std::io::ErrorKind::PermissionDenied => {
|
||||
Err(backoff::Error::Transient(err))
|
||||
}
|
||||
Err(err) => Err(backoff::Error::Permanent(err)),
|
||||
};
|
||||
let mut backoff = ExponentialBackoff {
|
||||
|
|
|
@ -254,7 +254,10 @@ impl TreeState {
|
|||
} else if metadata_file_type.is_symlink() {
|
||||
FileType::Symlink
|
||||
} else {
|
||||
#[cfg(unix)]
|
||||
let mode = metadata.permissions().mode();
|
||||
#[cfg(windows)]
|
||||
let mode = 0;
|
||||
if mode & 0o111 != 0 {
|
||||
FileType::Executable
|
||||
} else {
|
||||
|
@ -289,6 +292,19 @@ impl TreeState {
|
|||
let git_repo_dir = tempfile::tempdir().unwrap();
|
||||
let mut git_repo_options = RepositoryInitOptions::new();
|
||||
git_repo_options.workdir_path(&self.working_copy_path);
|
||||
// Repository::init_opts creates a ".git" file in the working copy,
|
||||
// which is undesired. On Windows it's worse because that ".git" makes
|
||||
// the next Repository::init_opts fail with "Permission Denied".
|
||||
// Automatically remove it.
|
||||
let _cleanup_dot_git = {
|
||||
struct Cleanup(PathBuf);
|
||||
impl Drop for Cleanup {
|
||||
fn drop(&mut self) {
|
||||
let _ = fs::remove_file(&self.0);
|
||||
}
|
||||
}
|
||||
Cleanup(self.working_copy_path.join(".git"))
|
||||
};
|
||||
let git_repo = Repository::init_opts(git_repo_dir.path(), &git_repo_options).unwrap();
|
||||
|
||||
let mut work = vec![(DirRepoPath::root(), self.working_copy_path.clone())];
|
||||
|
|
|
@ -36,6 +36,7 @@ fn count_non_merge_operations(repo: &ReadonlyRepo) -> u32 {
|
|||
num_ops
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test_case(false ; "local store")]
|
||||
#[test_case(true ; "git store")]
|
||||
fn test_commit_parallel(use_git: bool) {
|
||||
|
@ -68,6 +69,7 @@ fn test_commit_parallel(use_git: bool) {
|
|||
assert_eq!(count_non_merge_operations(&repo), 101);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test_case(false ; "local store")]
|
||||
#[test_case(true ; "git store")]
|
||||
fn test_commit_parallel_instances(use_git: bool) {
|
||||
|
|
|
@ -50,6 +50,7 @@ fn test_root(use_git: bool) {
|
|||
assert_eq!(wc_commit.committer().email, settings.user_email());
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test_case(false ; "local store")]
|
||||
#[test_case(true ; "git store")]
|
||||
fn test_checkout_file_transitions(use_git: bool) {
|
||||
|
@ -195,6 +196,7 @@ fn test_checkout_file_transitions(use_git: bool) {
|
|||
assert_eq!(maybe_metadata.is_ok(), true, "{:?} should exist", path);
|
||||
let metadata = maybe_metadata.unwrap();
|
||||
assert_eq!(metadata.is_file(), true, "{:?} should be a file", path);
|
||||
#[cfg(unix)]
|
||||
assert_eq!(
|
||||
metadata.permissions().mode() & 0o111,
|
||||
0,
|
||||
|
@ -206,6 +208,7 @@ fn test_checkout_file_transitions(use_git: bool) {
|
|||
assert_eq!(maybe_metadata.is_ok(), true, "{:?} should exist", path);
|
||||
let metadata = maybe_metadata.unwrap();
|
||||
assert_eq!(metadata.is_file(), true, "{:?} should be a file", path);
|
||||
#[cfg(unix)]
|
||||
assert_ne!(
|
||||
metadata.permissions().mode() & 0o111,
|
||||
0,
|
||||
|
|
|
@ -615,7 +615,11 @@ fn cmd_init(
|
|||
} else {
|
||||
repo = ReadonlyRepo::init_local(ui.settings(), wc_path);
|
||||
}
|
||||
writeln!(ui, "Initialized repo in {:?}", repo.working_copy_path());
|
||||
writeln!(
|
||||
ui,
|
||||
"Initialized repo in \"{}\"",
|
||||
repo.working_copy_path().display()
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -51,10 +51,12 @@ fn test_init_git_external() {
|
|||
assert!(repo_path.join(".jj").is_dir());
|
||||
let store_file_contents = std::fs::read_to_string(repo_path.join(".jj").join("store")).unwrap();
|
||||
assert!(store_file_contents.starts_with("git: "));
|
||||
assert!(store_file_contents.ends_with("/git-repo"));
|
||||
assert!(store_file_contents
|
||||
.replace('\\', "/")
|
||||
.ends_with("/git-repo"));
|
||||
assert_eq!(
|
||||
output.stdout_string(),
|
||||
format!("Initialized repo in \"{}\"\n", repo_path.to_str().unwrap())
|
||||
format!("Initialized repo in \"{}\"\n", repo_path.display())
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue