-
Notifications
You must be signed in to change notification settings - Fork 0
First serious attempt to fix issue #2 https://github.com/KarlHeitmann/git_explorer/issues/2 #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: refactor_explorer
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,8 @@ pub struct GitExplorer { | |
| stop_condition_i: usize, | ||
| stop_conditions: Vec<Option<BranchData>>, | ||
| nodes_len: usize, | ||
| abort: bool, | ||
| limit_stack: Option<usize>, | ||
| } | ||
|
|
||
| impl<'a> GitExplorer { | ||
|
|
@@ -69,6 +71,8 @@ impl<'a> GitExplorer { | |
| }; | ||
|
|
||
| Self { | ||
| abort: false, | ||
| limit_stack: Some(500), | ||
| stop_condition_i: 0, | ||
| repo, | ||
| root_oid, | ||
|
|
@@ -169,6 +173,28 @@ impl<'a> GitExplorer { | |
| } | ||
| // let branches = branches.map(|b| BranchData::new(b)).collect(); | ||
| self.paint_commit_track(self.repo.head().unwrap().peel_to_commit().unwrap(), branches) | ||
|
|
||
| /* | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are all the attempts I made to fix the error[0502] I've got when adding the |
||
| // self.paint_commit_track(self.repo.head().unwrap().peel_to_commit().unwrap(), self.repo.branches(Some(BranchType::Local)).unwrap()) | ||
| let x = self.paint_commit_track(self.repo.head().unwrap().peel_to_commit().unwrap(), self.repo.branches(Some(BranchType::Local)).unwrap()); | ||
| x | ||
| */ | ||
|
|
||
| /* | ||
| // let repo = &self.repo; | ||
| let branches = self.repo | ||
| .branches(Some(BranchType::Local)) | ||
| .unwrap(); | ||
| let head_data = self.repo.head().unwrap().peel_to_commit().unwrap().clone(); | ||
| self.paint_commit_track(head_data, branches) | ||
| */ | ||
| /* | ||
| let mut repo = &mut self.repo; | ||
| // let repo = &self.repo; | ||
| let mut branches = repo.branches(Some(BranchType::Local)).unwrap(); | ||
| let mut head_data = repo.head().unwrap().peel_to_commit().unwrap().clone(); | ||
| self.paint_commit_track(head_data, branches) | ||
| */ | ||
| } | ||
| }; | ||
| self.nodes_len = nodes.len(); | ||
|
|
@@ -204,23 +230,23 @@ impl<'a> GitExplorer { | |
| } | ||
|
|
||
| fn paint_branch( | ||
| &self, | ||
| &mut self, | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed immutable reference to self to mutable reference to self. I also need to change mutable reference to self in |
||
| mut commits: Vec<Commit>, | ||
| mut output: Vec<GraphNode>, | ||
| limit_stack: Option<usize>, | ||
| branches: Vec<BranchData>, | ||
| abort: bool) -> Vec<GraphNode> { | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| branches: Vec<BranchData>,) -> Vec<GraphNode> { | ||
| // fn paint_branch(mut commits: Vec<Commit>, mut output: Vec<(String, Oid)>, limit_stack: Option<usize>) -> Vec<(String, Oid)> { | ||
| // let debug_data: Vec<String> = commits.clone().into_iter().map(|c| short_id(c.id())).collect(); | ||
| // println!("{:?}", debug_data); | ||
| let l = commits.len(); | ||
| let mut status = Status::Same; | ||
|
|
||
| let (abort, limit_stack) = match limit_stack { | ||
| Some(limit_stack) => { (abort || l == 0 || limit_stack == 0, Some(limit_stack - 1))}, | ||
| None => {(abort || l == 0, None)} | ||
| let (abort, limit_stack) = match self.limit_stack { | ||
| Some(limit_stack) => { (self.abort || l == 0 || limit_stack == 0, Some(limit_stack - 1))}, | ||
| None => {(self.abort || l == 0, None)} | ||
| }; | ||
|
|
||
| self.limit_stack = limit_stack; | ||
|
|
||
| if abort { return vec![] } | ||
|
|
||
| let max_index = self.find_max_index(commits.clone().into_iter().map(|c| c.time()).collect()); | ||
|
|
@@ -304,26 +330,26 @@ impl<'a> GitExplorer { | |
| } | ||
|
|
||
| let stop_condition = self.stop_conditions.get(self.stop_condition_i).unwrap(); | ||
| let abort_next = match stop_condition { | ||
| self.abort = match stop_condition { | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line will need to mutate |
||
| Some(stop_condition) => { | ||
| stop_condition.oid() == commit_max.id() | ||
| } | ||
| _ => false | ||
| }; | ||
|
|
||
| let vec_str = self.paint_branch(dedup.to_vec(), vec![], limit_stack, branches, abort_next); | ||
| let vec_str = self.paint_branch(dedup.to_vec(), vec![], branches); | ||
|
|
||
| output.push(GraphNode { grapheme: paint_string, oid: commit_max.id(), branch_shorthand: shorthand, summary: commit_max.summary().unwrap().to_string() }); | ||
|
|
||
| [output, vec_str].concat() | ||
| } | ||
|
|
||
| pub fn paint_commit_track(&self, commit: Commit, branches: Vec<BranchData>) -> Vec<GraphNode> { | ||
| pub fn paint_commit_track(&mut self, commit: Commit, branches: Vec<BranchData>) -> Vec<GraphNode> { | ||
| // let limit_stack = 1000; // Works fine | ||
| let limit_stack = 500; // Works fine | ||
| // let limit_stack = 10000; // Works, but it is unhandeable :/ | ||
| // paint_branch(vec![commit], vec![], Some(limit_stack), branches) | ||
| self.paint_branch(vec![commit], vec![], Some(limit_stack), branches, false) | ||
| self.paint_branch(vec![commit], vec![], branches) | ||
| } | ||
|
|
||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created
abortandlimit_stackattributes created in GitExplorer struct, the idea is to remove the arguments here. Separate responsibilities, they are not necessary to be as arguments