-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #187 from vibinex/tr/phind/2.0
Diff Graph implementation
- Loading branch information
Showing
23 changed files
with
3,568 additions
and
32 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use crate::graph::mermaid_elements::generate_mermaid_flowchart; | ||
use crate::utils::user::ProviderEnum; | ||
use crate::utils::review::Review; | ||
use crate::core::github; | ||
use crate::utils::gitops::StatItem; | ||
|
||
pub async fn send_diff_graph(review: &Review, excluded_files: &Vec<StatItem>, small_files: &Vec<StatItem>, access_token: &str) { | ||
let comment = diff_graph_comment_text(excluded_files, small_files, review).await; | ||
// add comment for GitHub | ||
if review.provider().to_string() == ProviderEnum::Github.to_string() { | ||
log::info!("Inserting comment on repo {}...", review.repo_name()); | ||
github::comment::add_comment(&comment, review, &access_token).await; | ||
} | ||
|
||
// TODO: add comment for Bitbucket | ||
} | ||
|
||
async fn diff_graph_comment_text(excluded_files: &Vec<StatItem>, small_files: &Vec<StatItem>, review: &Review) -> String { | ||
let mut comment = "Diff Graph:\n\n".to_string(); | ||
|
||
let all_diff_files: Vec<StatItem> = excluded_files | ||
.iter() | ||
.chain(small_files.iter()) | ||
.cloned() // Clone the StatItem instances since `iter` returns references | ||
.collect(); // Collect into a new vector | ||
if let Some(mermaid_text) = mermaid_comment(&all_diff_files, review).await { | ||
comment += mermaid_text.as_str(); | ||
} | ||
comment += "\nTo modify DiffGraph settings, go to [your Vibinex settings page.](https://vibinex.com/settings)\n"; | ||
return comment; | ||
} | ||
|
||
async fn mermaid_comment(diff_files: &Vec<StatItem>, review: &Review) -> Option<String> { | ||
let flowchart_str_opt = generate_mermaid_flowchart(diff_files, review).await; | ||
if flowchart_str_opt.is_none() { | ||
log::error!("[mermaid_comment] Unable to generate flowchart for review: {}", review.id()); | ||
return None; | ||
} | ||
let flowchart_str = flowchart_str_opt.expect("Empty flowchart_str_opt"); | ||
let mermaid_comment = format!( | ||
"### Call Stack Diff\n```mermaid\n{}\n```", | ||
flowchart_str, | ||
); | ||
return Some(mermaid_comment); | ||
} | ||
|
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
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
Oops, something went wrong.