Skip to content

Commit

Permalink
add API to check if there are merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
gschoeni committed Apr 13, 2023
1 parent e6bf088 commit 1990dcb
Show file tree
Hide file tree
Showing 18 changed files with 461 additions and 126 deletions.
31 changes: 31 additions & 0 deletions MergeConflict.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Merge Conflict

Here are some commands to generate a merge conflict:

```bash
# create empty directory
$ mkdir merge-conflict-demo
$ cd merge-conflict-demo

# create a new oxen repo and add a test csv file on main
$ oxen init
$ echo "file,label" > test.csv
$ echo "images/dog.png,dog" >> test.csv
$ oxen add test.csv
$ oxen commit -m "adding a dog"

# checkout a new branch where you are going to append a cat
$ oxen checkout -b "adding-cat"
$ echo "images/cat.png,cat" >> test.csv
$ oxen add test.csv
$ oxen commit -m "adding a cat"

# checkout the main branch again, and append a fish
$ oxen checkout main
$ echo "images/fish.png,fish" >> test.csv
$ oxen add test.csv
$ oxen commit -m "adding a fish"

# try to merge the branch with the cat (should fail)
$ oxen merge adding-cat
```
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,6 @@ You can grab your auth token from the config file above (~/.oxen/user_config.tom

`curl -H "Authorization: Bearer $TOKEN" -X POST -d '{"name": "MyRepo"}' "http://$SERVER/repositories"`

## Add file

`curl -v -H "Authorization: Bearer $TOKEN" -X POST --data-binary @/Users/gregschoeninger/Downloads/woof_meow.jpeg "http://$SERVER/repositories/MyRepo/entries?id=1234&path=woof_meow.jpeg&is_synced=true&hash=4321&commit_id=1234&extension=jpeg"`

# Docker

Create the docker image
Expand Down
12 changes: 6 additions & 6 deletions src/lib/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -877,22 +877,22 @@ pub fn checkout_combine<P: AsRef<Path>>(repo: &LocalRepository, path: P) -> Resu
.iter()
.find(|c| c.merge_entry.path == path.as_ref())
{
if util::fs::is_tabular(&conflict.head_entry.path) {
let df_head_path = util::fs::version_path(repo, &conflict.head_entry);
let df_head = tabular::read_df(df_head_path, DFOpts::empty())?;
if util::fs::is_tabular(&conflict.base_entry.path) {
let df_base_path = util::fs::version_path(repo, &conflict.base_entry);
let df_base = tabular::read_df(df_base_path, DFOpts::empty())?;
let df_merge_path = util::fs::version_path(repo, &conflict.merge_entry);
let df_merge = tabular::read_df(df_merge_path, DFOpts::empty())?;

log::debug!("GOT DF HEAD {}", df_head);
log::debug!("GOT DF HEAD {}", df_base);
log::debug!("GOT DF MERGE {}", df_merge);

match df_head.vstack(&df_merge) {
match df_base.vstack(&df_merge) {
Ok(result) => {
log::debug!("GOT DF COMBINED {}", result);
match result.unique(None, polars::frame::UniqueKeepStrategy::First) {
Ok(mut uniq) => {
log::debug!("GOT DF COMBINED UNIQUE {}", uniq);
let output_path = repo.path.join(&conflict.head_entry.path);
let output_path = repo.path.join(&conflict.base_entry.path);
tabular::write_df(&mut uniq, &output_path)
}
_ => Err(OxenError::basic_str("Could not uniq data")),
Expand Down
Loading

0 comments on commit 1990dcb

Please sign in to comment.