Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
yuja committed Dec 21, 2024
1 parent 75ce7f6 commit d8ad009
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ jobs:
fail-fast: false
matrix:
# macos-13 is x86; macos-14 is ARM
os: [ubuntu-latest, macos-13, macos-14, windows-latest]
os: [windows-latest]
cargo_flags: [""]
include:
- os: ubuntu-latest
cargo_flags: "--all-features"
runs-on: ${{ matrix.os }}

# TODO FIXME (aseipp): keep the timeout limit to ~15 minutes. this is long
Expand Down Expand Up @@ -75,7 +72,7 @@ jobs:
- name: Build
run: cargo build --workspace --all-targets --verbose ${{ matrix.cargo_flags }}
- name: Test
run: cargo test --workspace --all-targets --verbose ${{ matrix.cargo_flags }}
run: cargo test --workspace --all-targets --verbose ${{ matrix.cargo_flags }} -- git_push
env:
RUST_BACKTRACE: 1

Expand Down
23 changes: 7 additions & 16 deletions cli/src/commands/git/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,12 @@ pub struct GitCloneArgs {
depth: Option<NonZeroU32>,
}

fn absolute_git_source(cwd: &Path, source: &str) -> String {
// Git appears to turn URL-like source to absolute path if local git directory
// exits, and fails because '$PWD/https' is unsupported protocol. Since it would
// be tedious to copy the exact git (or libgit2) behavior, we simply assume a
// source containing ':' is a URL, SSH remote, or absolute path with Windows
// drive letter.
if !source.contains(':') && Path::new(source).exists() {
// It's less likely that cwd isn't utf-8, so just fall back to original source.
cwd.join(source)
.into_os_string()
.into_string()
.unwrap_or_else(|_| source.to_owned())
} else {
source.to_owned()
}
fn absolute_git_source(cwd: &Path, source: &str) -> Result<String, CommandError> {
let mut url = gix::Url::from_bytes(source.as_ref()).map_err(user_error)?;
url.canonicalize(cwd).map_err(user_error)?;
dbg!(&url);
// It's less likely that cwd isn't utf-8, so just fall back to original source.
Ok(String::from_utf8(url.to_bstring().into()).unwrap_or_else(|_| source.to_owned()))
}

fn clone_destination_for_source(source: &str) -> Option<&str> {
Expand Down Expand Up @@ -107,7 +98,7 @@ pub fn cmd_git_clone(
if command.global_args().at_operation.is_some() {
return Err(cli_error("--at-op is not respected"));
}
let source = absolute_git_source(command.cwd(), &args.source);
let source = absolute_git_source(command.cwd(), &args.source)?;
let wc_path_str = args
.destination
.as_deref()
Expand Down
9 changes: 8 additions & 1 deletion cli/tests/test_git_push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ fn set_up() -> (TestEnvironment, PathBuf) {
],
);
let workspace_root = test_env.env_root().join("local");
eprintln!(
"git config:\n{}",
std::fs::read_to_string(workspace_root.join(PathBuf::from_iter([
".jj", "repo", "store", "git", "config"
])))
.unwrap()
);
(test_env, workspace_root)
}

Expand Down Expand Up @@ -1387,7 +1394,7 @@ fn test_git_push_moved_sideways_untracked() {

#[test]
// TODO: This test fails with libgit2 v1.8.1 on Windows.
#[cfg(not(target_os = "windows"))]
//#[cfg(not(target_os = "windows"))]
fn test_git_push_to_remote_named_git() {
let (test_env, workspace_root) = set_up();
let git_repo = {
Expand Down

0 comments on commit d8ad009

Please sign in to comment.