file blame at right revision from commit-details (#1324)

This commit is contained in:
Niko Heiskanen 2022-09-18 15:06:46 +03:00 committed by GitHub
parent 30918d114c
commit 0a970db24a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View File

@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* 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))

View File

@ -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)));

View File

@ -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};
@ -35,6 +35,7 @@ pub struct StatusTreeComponent {
key_config: SharedKeyConfig,
scroll_top: Cell<usize>,
visible: bool,
revision: Option<CommitId>,
}
impl StatusTreeComponent {
@ -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;
@ -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,
},
),