Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9f9828f
Rework logic for git xet repo migrate.
Jun 15, 2024
4652f68
Typo.
Jun 17, 2024
6697722
Update module name.
Jun 17, 2024
57804c1
Updates to module name.
Jun 17, 2024
aff589d
Update.
Jun 17, 2024
f7370ce
Updates.
Jun 17, 2024
72cb31f
Fixed issue with duplicate counting.
Jun 17, 2024
0312b7d
Updates.
Jun 17, 2024
93550ce
Renamed back to downstream.
Jun 17, 2024
561116a
Updates for debugging.
Jun 17, 2024
b289602
Updates.
Jun 17, 2024
f8ceb97
Updates 123.
Jun 17, 2024
7872bd8
Update 124
Jun 17, 2024
430493d
Updated some logic.
Jun 18, 2024
c1d411b
Updated some logic.
Jun 18, 2024
246a7ef
Update. fixed?
Jun 18, 2024
715fdf3
Updates, perhaps working.
Jun 18, 2024
fda9db0
Okay, this should work.
Jun 18, 2024
a9c8712
Removed bad check.
Jun 18, 2024
24bb39c
Update, works.
Jun 18, 2024
a9e3b32
Logic fixed.
Jun 18, 2024
372c43a
Corrected error message.
Jun 18, 2024
4b3fd98
Updated note tree propegatation.
Jun 18, 2024
943814f
Updated logic for note tree conversion.
Jun 18, 2024
8760754
Updated note tree stuff.
Jun 18, 2024
103a3cb
Update to not pull in non-note trees as note trees.
Jun 18, 2024
d6933f3
Updated refs notes setting.
Jun 18, 2024
83b93e3
More about xet notes.
Jun 18, 2024
695ae04
Updated note commit detection logic.
Jun 18, 2024
4bb376e
Updated.
Jun 18, 2024
6849824
Testing repo cycle conversion.
Jun 18, 2024
a855fb7
Update to fix filemode issues.
Jun 18, 2024
69b5fbb
Clippy issues.
Jun 18, 2024
7db288a
Merge branch 'hoytak/240611-git-xet-migrate-port-notes-no-cycle' into…
Jun 18, 2024
160d2a8
Update.
Jun 18, 2024
486c98b
Clippy errors.
Jun 18, 2024
99b344f
Turn off tracing.
Jun 18, 2024
e81ee20
Update.
Jun 18, 2024
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
19 changes: 19 additions & 0 deletions gitxet/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions gitxet/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ mod git_integration_tests {
fn test_xet_lazy() -> anyhow::Result<()> {
IntegrationTest::new(include_str!("integration_tests/test_xet_lazy.sh")).run()
}

#[test]
fn test_repo_migration() -> anyhow::Result<()> {
IntegrationTest::new(include_str!("integration_tests/test_repo_migration.sh")).run()
}
}

#[cfg(test)]
Expand Down
147 changes: 147 additions & 0 deletions gitxet/tests/integration_tests/test_repo_migration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#!/bin/bash

SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )";
. "$SCRIPT_DIR/initialize.sh"
setup_basic_run_environment

mkdir src_repo

mkdir main
mkdir br1
mkdir br2
mkdir br3
mkdir br4

pushd src_repo
git init
echo "Testing" > test.txt
git add *
git commit -a -m "Initial commit."

create_data_file data.dat 100
git add *
git commit -a -m "main."
cp * ../main/

git checkout -b br1
create_data_file data2.dat 100
cp data2.dat data2b.dat
git add *
git commit -a -m "br1"
cp * ../br1/

# Replace the original data file.
git checkout -b br2
create_data_file data.dat 100
git add *
git commit -a -m "br2"
cp * ../br2/

# Replace the second data file and duplicate the data2.dat
git checkout -b br3
create_data_file data3.dat 100
git add *
git commit -a -m "br3"
cp * ../br3/

git checkout main
git checkout -b br4
git merge br1 --no-edit
git merge br2 --no-edit
git merge br3 --no-edit
cp data.dat data3b.dat
create_data_file data3.dat 100
git add *
git commit -a -m "br4"
cp * ../br4/


# Add a bunch of notes there too.
add_note_to_branch_head() {
local repo=$1
local branch=$2
local note_content=$3

git -C "$repo" checkout "$branch"
}

# Step 1: Add test notes to SRC_REPO
echo "Adding test notes to SRC_REPO..."

note_branches="main br1 br2 br3"

for branch in $note_branches ; do

git checkout $branch
head_commit=$(git rev-parse HEAD)

git notes add -m "Test note: $branch" $head_commit
done
popd

xet_remote=$(create_bare_repo)
pushd $xet_remote
git xet init --force
popd

ls ./src_repo
git xet repo migrate --src=./src_repo --dest=$xet_remote --working-dir=./migration_working_dir --no-cleanup

# Now, do a clone from the local folder.
git xet clone $xet_remote migrated_repo

pushd ./migrated_repo
git fetch origin "refs/notes/*:refs/notes/*"

# Verify all the data files are correct.
git checkout main
assert_stored_as_pointer_file data.dat
for f in * ; do
assert_files_equal $f ../main/$f
done

# Verify all the data files are correct.
git checkout br1
assert_stored_as_pointer_file data.dat
assert_stored_as_pointer_file data2.dat
for f in * ; do
assert_files_equal $f ../br1/$f
done

git checkout br2
assert_stored_as_pointer_file data.dat
assert_stored_as_pointer_file data2.dat
assert_stored_as_pointer_file data2b.dat
for f in * ; do
assert_files_equal $f ../br2/$f
done

git checkout br3
assert_stored_as_pointer_file data.dat
assert_stored_as_pointer_file data2.dat
assert_stored_as_pointer_file data2b.dat
assert_stored_as_pointer_file data3.dat
for f in * ; do
assert_files_equal $f ../br3/$f
done

git checkout br4
assert_stored_as_pointer_file data.dat
assert_stored_as_pointer_file data2.dat
assert_stored_as_pointer_file data3.dat
assert_stored_as_pointer_file data3b.dat
for f in * ; do
assert_files_equal $f ../br4/$f
done


for branch in $note_branches ; do
git checkout $branch
head_commit=$(git rev-parse HEAD)

note_content="$(git notes show $head_commit || echo "NOT FOUND")"
if [[ $note_content != "Test note: $branch" ]]; then
die "Note for branch $branch not found or incorrect: ($note_content)"
fi
done

19 changes: 19 additions & 0 deletions libxet/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions rust/gitxetcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ prometheus = "0.13.0"
prometheus_dict_encoder = { path = "../prometheus_dict_encoder" }
utime = "0.3.1"

# Other hashers for migration
hashers = "1.0.1"

# Need to specify this as optional to allow the openssl/vendored option below
openssl = { version = "0.10", features = [], optional = true }
Expand Down
42 changes: 39 additions & 3 deletions rust/gitxetcore/src/command/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ async fn migrate_command(config: XetConfig, args: &MigrateArgs) -> Result<()> {
let xet_repo = GitXetRepo::open_and_verify_setup(config.clone()).await?;

// Now do the actual migration process.
let branch_list = migrate_repo(&source_dir, &xet_repo).await?;
let (branch_list, ref_list) = migrate_repo(&source_dir, &xet_repo).await?;

eprintln!("Migration complete; packing repository at {dest_dir:?}.");
run_git_passthrough(
Expand Down Expand Up @@ -228,7 +228,7 @@ async fn migrate_command(config: XetConfig, args: &MigrateArgs) -> Result<()> {
) {
if slice_size == 1 {
eprintln!("Error updating remote branch {}.", branches_this_push[0]);
eprintln!("Please go to directory {dest_dir:?} and run `git push --force --set-upstream {}` to push manually.", branches_this_push[0]);
eprintln!("Please go to directory {dest_dir:?} and run `git push --force --set-upstream origin {}` to push manually.", branches_this_push[0]);

Err(e)?;
unreachable!();
Expand All @@ -239,13 +239,49 @@ async fn migrate_command(config: XetConfig, args: &MigrateArgs) -> Result<()> {
}
}
// Success, now loop.
start_idx += slice_size;
start_idx += branches_this_push.len();
eprintln!(
"Synced {start_idx} / {} branches.",
remaining_branches.len()
);
}

eprintln!("Syncing tags.");
run_git_passthrough(
Some(&dest_dir),
"push",
&["origin", "--force", "--tags", "--follow-tags"],
true,
false,
Some(&[("XET_DISABLE_HOOKS", "0")]),
).map_err(|e| {
eprintln!("Error pushing to remote.");
eprintln!("Please go to directory {dest_dir:?} and run `git push origin --force --tags --follow-tags --all` to push manually.");
e
})?;

if !ref_list.is_empty() {
eprintln!("Syncing remaining references.");
let mut args = vec!["origin".to_owned()];

for r in ref_list {
args.push(format!("+{r}:{r}"));
}

run_git_passthrough(
Some(&dest_dir),
"push",
&args.iter().map(|s| s.as_str()).collect::<Vec<&str>>(),
true,
false,
Some(&[("XET_DISABLE_HOOKS", "0")]),
).map_err(|e| {
eprintln!("Error pushing to remote.");
eprintln!("Please go to directory {dest_dir:?} and run `git push origin +refs/*:refs/*` to push manually.");
e
})?;
}

if !args.no_cleanup {
eprintln!("Cleaning up.");
let _ = std::fs::remove_dir_all(&source_dir).map_err(|e| {
Expand Down
2 changes: 1 addition & 1 deletion rust/gitxetcore/src/diff/csv.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::borrow::Cow;
use serde::{Deserialize, Serialize};
use std::borrow::Cow;
use tracing::warn;

use crate::diff::error::DiffError;
Expand Down
2 changes: 1 addition & 1 deletion rust/gitxetcore/src/diff/processor.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::borrow::Cow;
use crate::diff::error::DiffError;
use crate::diff::output::{SummaryDiff, SummaryDiffData};
use crate::summaries::analysis::FileSummary;
use crate::summaries::summary_type::SummaryType;
use std::borrow::Cow;

/// Trait that different types of summaries can implement to generate diffs.
///
Expand Down
2 changes: 1 addition & 1 deletion rust/gitxetcore/src/diff/tds.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::borrow::Cow;
use crate::diff::output::SummaryDiffData;
use crate::diff::output::SummaryDiffData::Tds;
use crate::diff::{DiffError, SummaryDiffProcessor};
use crate::summaries::{FileSummary, SummaryType};
use std::borrow::Cow;
use tableau_summary::tds::diff::schema::TdsSummaryDiffContent;
use tableau_summary::tds::TdsSummary;
use tableau_summary::twb::diff::util::DiffProducer;
Expand Down
26 changes: 14 additions & 12 deletions rust/gitxetcore/src/git_integration/git_process_wrapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,22 @@ fn spawn_git_command(
}
}

if let Some(dir) = base_directory {
debug_assert!(dir.exists());
let cwd = std::env::current_dir()?;
let run_dir = base_directory.unwrap_or(&cwd);

debug_assert!(run_dir.exists());
cmd.current_dir(run_dir);

cmd.current_dir(dir);
}
debug!(
"Calling git, working dir={:?}, command = git {:?} {:?}, env = {:?}",
match base_directory {
Some(bd) => bd.to_owned(),
None => std::env::current_dir()?,
},
&command,
&args,
&env
"Calling git, base_dir={}, run_dir={run_dir:?}, command = git {command:?} {}, env: {}",
base_directory
.map(|d| d.to_str().unwrap_or("bad"))
.unwrap_or("None"),
args.iter().map(|a| format!("\"{a}\"")).join(" "),
env.unwrap_or_default()
.iter()
.map(|(k, v)| format!("{k}=\"{v}\""))
.join(" "),
);

// Using idea from https://stackoverflow.com/questions/30776520/closing-stdout-or-stdin
Expand Down
2 changes: 1 addition & 1 deletion rust/gitxetcore/src/git_integration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ mod git_repo_plumbing;
pub mod git_repo_salt;
mod git_xet_repo;
pub mod hook_command_entry;
pub mod repo_migration;

pub mod git_url;
pub mod git_user_config;
Expand All @@ -21,3 +20,4 @@ pub use git_process_wrapping::*;
pub use git_repo_paths::*;
pub use git_repo_plumbing::*;
pub use git_xet_repo::GitXetRepo;
pub mod repo_migration;
Loading