Skip to content
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

file blame at right revision from commit-details #1324

Merged
merged 3 commits into from
Sep 18, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

![submodules](assets/submodules.gif)


heiskane marked this conversation as resolved.
Show resolved Hide resolved
### Added
* submodules support ([#1087](https://github.com/extrawurst/gitui/issues/1087))
* customizable `cmdbar_bg` theme color & screen spanning selected line bg [[@gigitsu](https://github.com/gigitsu)] ([#1299](https://github.com/extrawurst/gitui/pull/1299))
* use filewatcher instead of polling updates ([#1](https://github.com/extrawurst/gitui/issues/1))
* word motions to text input [[@Rodrigodd](https://github.com/Rodrigodd)] ([#1256](https://github.com/extrawurst/gitui/issues/1256))
* file blame at right revision from commit-details [[@heiskane](https://github.com/heiskane)] ([#1122](https://github.com/extrawurst/gitui/issues/1122))

### Fixes
* remove insecure dependency `ansi_term` ([#1290](https://github.com/extrawurst/gitui/issues/1290))
Expand Down
2 changes: 2 additions & 0 deletions src/components/commit_details/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ impl CommitDetailsComponent {
self.commit = params;

if let Some(id) = params {
self.file_tree.set_commit(Some(id.id));

if let Some(other) = id.other {
self.compare_details
.set_commits(Some((id.id, other)));
Expand Down
10 changes: 8 additions & 2 deletions src/components/status_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
ui::style::SharedTheme,
};
use anyhow::Result;
use asyncgit::{hash, StatusItem, StatusItemType};
use asyncgit::{hash, sync::CommitId, StatusItem, StatusItemType};
use crossterm::event::Event;
use std::{borrow::Cow, cell::Cell, convert::From, path::Path};
use tui::{backend::Backend, layout::Rect, text::Span, Frame};
Expand All @@ -35,6 +35,7 @@ pub struct StatusTreeComponent {
key_config: SharedKeyConfig,
scroll_top: Cell<usize>,
visible: bool,
revision: Option<CommitId>,
}

impl StatusTreeComponent {
Expand All @@ -58,9 +59,14 @@ impl StatusTreeComponent {
scroll_top: Cell::new(0),
pending: true,
visible: false,
revision: None,
}
}

pub fn set_commit(&mut self, revision: Option<CommitId>) {
self.revision = revision;
}

///
pub fn update(&mut self, list: &[StatusItem]) -> Result<()> {
self.pending = false;
Expand Down Expand Up @@ -428,7 +434,7 @@ impl Component for StatusTreeComponent {
StackablePopupOpen::BlameFile(
BlameFileOpen {
file_path: status_item.path,
commit_id: None,
commit_id: self.revision,
selection: None,
},
),
Expand Down