Skip to content

Commit 2e27d4b

Browse files
committed
refactored and compiling
1 parent 9622e44 commit 2e27d4b

File tree

6 files changed

+35
-17
lines changed

6 files changed

+35
-17
lines changed

src/cli/src/cmd_setup.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -818,14 +818,14 @@ pub fn diff() -> Command {
818818
.arg(Arg::new("keys")
819819
.required(false)
820820
.long("keys")
821-
.short("k")
821+
.short('k')
822822
.help("Comma-separated list of columns to compare on. If not specified, all columns are used for comparison.")
823823
.use_value_delimiter(true)
824824
.action(clap::ArgAction::Set))
825825
.arg(Arg::new("targets")
826826
.required(false)
827827
.long("targets")
828-
.short("t")
828+
.short('t')
829829
.help("Comma-separated list of columns in which to view changes. If not specified, all columns are viewed")
830830
.use_value_delimiter(true)
831831
.action(clap::ArgAction::Set))

src/cli/src/dispatch.rs

-6
Original file line numberDiff line numberDiff line change
@@ -519,12 +519,6 @@ pub async fn diff(
519519
let current_commit = api::local::commits::head_commit(&repository)?;
520520
// For revision_1 and revision_2, if none, set to current_commit
521521
// let revision_1 = revision_1.unwrap_or(current_commit.id.as_str());
522-
// let revision_2 = revision_2.unwrap_or(current_commit.id.as_str());
523-
524-
let commit_1 = api::local::revisions::get(&repository, revision_1)?
525-
.ok_or_else(|| OxenError::revision_not_found(revision_1.into()))?;
526-
let commit_2 = api::local::revisions::get(&repository, revision_2)?
527-
.ok_or_else(|| OxenError::revision_not_found(revision_2.into()))?;
528522

529523
// TODONOW: might be able to clean this logic up - pull out into function so we can early return and be less confusing
530524
let (cpath_1, cpath_2) = if let Some(file_2) = file_2 {

src/cli/src/parse_and_run.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -943,11 +943,18 @@ pub async fn pull(sub_matches: &ArgMatches) {
943943
}
944944
}
945945

946-
pub async fn diff(sub_matches: &ArgMatches) {
946+
pub async fn remote_diff(sub_matches: &ArgMatches) {
947+
log::debug!("in remote diff...");
947948
let is_remote = true;
948949
p_diff(sub_matches, is_remote).await
949950
}
950951

952+
pub async fn diff(sub_matches: &ArgMatches) {
953+
log::debug!("parse and run diff");
954+
let is_remote = false;
955+
p_diff(sub_matches, is_remote).await
956+
}
957+
951958
async fn p_diff(sub_matches: &ArgMatches, is_remote: bool) {
952959
let resource1 = sub_matches
953960
.get_one::<String>("RESOURCE1")
@@ -961,7 +968,7 @@ async fn p_diff(sub_matches: &ArgMatches, is_remote: bool) {
961968
let (file2, revision2) = match resource2 {
962969
Some(resource) => {
963970
let (file, revision) = parse_file_and_revision(resource);
964-
(Some(PathBuf::from(file)), Some(revision))
971+
(Some(PathBuf::from(file)), revision)
965972
}
966973
None => (None, None),
967974
};

src/lib/src/api/local/compare.rs

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub fn compare_files(
4444
targets: Vec<String>,
4545
output: Option<PathBuf>,
4646
) -> Result<CompareResult, OxenError> {
47+
log::debug!("comparing files");
4748
// Assert that the files exist in their respective commits.
4849
let file_1 = get_version_file(repo, &compare_entry_1)?;
4950
let file_2 = get_version_file(repo, &compare_entry_2)?;

src/lib/src/command/compare.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ pub fn compare(
1313
keys: Vec<String>,
1414
targets: Vec<String>,
1515
output: Option<PathBuf>,
16-
) -> Result<(), OxenError> {
16+
) -> Result<String, OxenError> {
1717
// TODONOW - anything we can clean up with this mut initialization?
18+
log::debug!("in the compare...");
1819
let mut compare_entry_1 = CompareEntry {
1920
commit_entry: None,
2021
path: cpath_1.path.clone(),
@@ -64,10 +65,11 @@ pub fn compare(
6465
output,
6566
)?;
6667

68+
log::debug!("compare result: {:?}", compare_result);
69+
6770
let text = match compare_result {
6871
CompareResult::Tabular((_, text)) => text,
6972
CompareResult::Text(text) => text,
7073
};
71-
println!("{}", text);
72-
Ok(())
74+
Ok(text)
7375
}

src/lib/src/model/compare/tabular_compare.rs

+18-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,22 @@ pub struct TabularCompare {
2020
#[derive(Deserialize, Serialize, Debug, Clone)]
2121
pub struct TabularCompareBody {
2222
pub compare_id: String,
23-
pub left_resource: String,
24-
pub right_resource: String,
25-
pub keys: Vec<String>,
26-
pub targets: Vec<String>,
23+
pub left: TabularCompareResourceBody,
24+
pub right: TabularCompareResourceBody,
25+
pub keys: Vec<TabularCompareFieldBody>,
26+
pub compare: Vec<TabularCompareFieldBody>,
27+
pub display: Vec<TabularCompareFieldBody>,
28+
}
29+
30+
#[derive(Deserialize, Serialize, Debug, Clone)]
31+
pub struct TabularCompareResourceBody {
32+
pub path: String,
33+
pub version: String,
34+
}
35+
36+
#[derive(Deserialize, Serialize, Debug, Clone)]
37+
pub struct TabularCompareFieldBody {
38+
pub left: String,
39+
pub right: String,
40+
pub alias: Option<String>,
2741
}

0 commit comments

Comments
 (0)