-
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
Showing
10 changed files
with
90 additions
and
9 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
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pub struct ArchHunk { | ||
pub filename: String, | ||
pub old_arch: String, | ||
pub new_arch: String, | ||
} |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use std::fmt::Display; | ||
|
||
use git2::DiffLine; | ||
|
||
pub trait ArchDiff: Display { | ||
fn arch_diff(&mut self, filename: &str, diff: &DiffLine); | ||
} |
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,50 @@ | ||
use std::fmt::Display; | ||
use std::ops::Add; | ||
|
||
use diffy::create_patch; | ||
use git2::DiffLine; | ||
|
||
use crate::languages::arch_diff::ArchDiff; | ||
|
||
struct JavaArchDiff { | ||
filename: String, | ||
old_arch: String, | ||
new_arch: String, | ||
diff: String, | ||
} | ||
|
||
impl JavaArchDiff { | ||
fn flush(&mut self) { | ||
let old = &self.old_arch; | ||
let new = &self.new_arch; | ||
let diff = create_patch(old, new); | ||
let diff = diff.to_string(); | ||
self.diff += &diff | ||
} | ||
} | ||
|
||
impl Display for JavaArchDiff { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
write!(f, "{}", self.diff) | ||
} | ||
} | ||
|
||
impl ArchDiff for JavaArchDiff { | ||
fn arch_diff(&mut self, filename: &str, diff: &DiffLine) { | ||
todo!() | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use diffy::{create_patch, DiffOptions}; | ||
|
||
#[test] | ||
fn it_works() { | ||
let old = "ool\nkek\njey trek\n"; | ||
let new = "lol\nkek\njey trep"; | ||
let diff = create_patch(old, new); | ||
println!("{}", 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mod arch_diff; | ||
|
||
mod java_arch_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
mod git; | ||
mod arch; | ||
mod arch_hunk; | ||
|
||
mod languages; | ||
|
||
|
||
fn main() {} |