-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ebbcccc
commit 6d649ae
Showing
7 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pub mod auth; | ||
pub mod cob; | ||
pub mod diff; | ||
pub mod profile; | ||
pub mod repo; | ||
pub mod thread; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use radicle::storage::ReadStorage; | ||
use radicle_surf as surf; | ||
|
||
use radicle::git; | ||
use radicle::identity; | ||
use serde::Deserialize; | ||
use serde::Serialize; | ||
|
||
use crate::{error, AppState}; | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct Options { | ||
pub base: git::Oid, | ||
pub head: git::Oid, | ||
pub unified: u32, | ||
} | ||
|
||
#[tauri::command] | ||
pub async fn get_diff( | ||
ctx: tauri::State<'_, AppState>, | ||
rid: identity::RepoId, | ||
options: Options, | ||
) -> Result<surf::diff::Diff, error::Error> { | ||
let repo = ctx.profile.storage.repository(rid)?.backend; | ||
let base = repo.find_commit(*options.base)?; | ||
let head = repo.find_commit(*options.head)?; | ||
|
||
let mut opts = git::raw::DiffOptions::new(); | ||
opts.patience(true) | ||
.minimal(true) | ||
.context_lines(options.unified); | ||
|
||
let mut find_opts = git::raw::DiffFindOptions::new(); | ||
find_opts.exact_match_only(true); | ||
find_opts.all(true); | ||
|
||
let left = base.tree()?; | ||
let right = head.tree()?; | ||
|
||
let mut diff = repo.diff_tree_to_tree(Some(&left), Some(&right), Some(&mut opts))?; | ||
diff.find_similar(Some(&mut find_opts))?; | ||
let diff = surf::diff::Diff::try_from(diff)?; | ||
|
||
Ok::<_, error::Error>(diff) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters