mirror of
https://github.com/extrawurst/gitui.git
synced 2024-12-28 19:44:14 +03:00
Search commits by author (#1822)
This commit is contained in:
parent
d253022f13
commit
cde1c7f883
@ -65,13 +65,13 @@ bitflags! {
|
||||
const MESSAGE = 0b0000_0001;
|
||||
///
|
||||
const FILENAMES = 0b0000_0010;
|
||||
///
|
||||
const AUTHORS = 0b0000_0100;
|
||||
//TODO:
|
||||
// const COMMIT_HASHES = 0b0000_0100;
|
||||
// ///
|
||||
// const DATES = 0b0000_1000;
|
||||
// ///
|
||||
// const AUTHORS = 0b0001_0000;
|
||||
// ///
|
||||
// const DIFFS = 0b0010_0000;
|
||||
}
|
||||
}
|
||||
@ -210,7 +210,27 @@ pub fn filter_commit_by_search(
|
||||
.map(|diff| filter.match_diff(&diff))
|
||||
.unwrap_or_default();
|
||||
|
||||
Ok(msg_match || file_match)
|
||||
let authors_match = filter
|
||||
.options
|
||||
.fields
|
||||
.contains(SearchFields::AUTHORS)
|
||||
.then(|| {
|
||||
let name_match = commit
|
||||
.author()
|
||||
.name()
|
||||
.map(|name| filter.match_text(name))
|
||||
.unwrap_or_default();
|
||||
let mail_match = commit
|
||||
.author()
|
||||
.email()
|
||||
.map(|name| filter.match_text(name))
|
||||
.unwrap_or_default();
|
||||
|
||||
name_match || mail_match
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
Ok(msg_match || file_match || authors_match)
|
||||
},
|
||||
))
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ enum Selection {
|
||||
CaseOption,
|
||||
MessageSearch,
|
||||
FilenameSearch,
|
||||
AuthorsSearch,
|
||||
}
|
||||
|
||||
pub struct LogSearchPopupComponent {
|
||||
@ -111,6 +112,13 @@ impl LogSearchPopupComponent {
|
||||
" "
|
||||
};
|
||||
|
||||
let x_authors =
|
||||
if self.options.0.contains(SearchFields::AUTHORS) {
|
||||
"X"
|
||||
} else {
|
||||
" "
|
||||
};
|
||||
|
||||
let x_opt_fuzzy =
|
||||
if self.options.1.contains(SearchOptions::FUZZY_SEARCH) {
|
||||
"X"
|
||||
@ -161,15 +169,21 @@ impl LogSearchPopupComponent {
|
||||
false,
|
||||
),
|
||||
)]),
|
||||
Line::from(vec![Span::styled(
|
||||
format!("[{x_authors}] authors",),
|
||||
self.theme.text(
|
||||
matches!(
|
||||
self.selection,
|
||||
Selection::AuthorsSearch
|
||||
),
|
||||
false,
|
||||
),
|
||||
)]),
|
||||
// Line::from(vec![Span::styled(
|
||||
// "[ ] changes (soon)",
|
||||
// theme,
|
||||
// )]),
|
||||
// Line::from(vec![Span::styled(
|
||||
// "[ ] authors (soon)",
|
||||
// theme,
|
||||
// )]),
|
||||
// Line::from(vec![Span::styled(
|
||||
// "[ ] hashes (soon)",
|
||||
// theme,
|
||||
// )]),
|
||||
@ -192,14 +206,21 @@ impl LogSearchPopupComponent {
|
||||
Selection::MessageSearch => {
|
||||
self.options.0.toggle(SearchFields::MESSAGE);
|
||||
|
||||
if !self.options.0.contains(SearchFields::MESSAGE) {
|
||||
if self.options.0.is_empty() {
|
||||
self.options.0.set(SearchFields::FILENAMES, true);
|
||||
}
|
||||
}
|
||||
Selection::FilenameSearch => {
|
||||
self.options.0.toggle(SearchFields::FILENAMES);
|
||||
|
||||
if !self.options.0.contains(SearchFields::FILENAMES) {
|
||||
if self.options.0.is_empty() {
|
||||
self.options.0.set(SearchFields::AUTHORS, true);
|
||||
}
|
||||
}
|
||||
Selection::AuthorsSearch => {
|
||||
self.options.0.toggle(SearchFields::AUTHORS);
|
||||
|
||||
if self.options.0.is_empty() {
|
||||
self.options.0.set(SearchFields::MESSAGE, true);
|
||||
}
|
||||
}
|
||||
@ -210,11 +231,12 @@ impl LogSearchPopupComponent {
|
||||
if arg {
|
||||
//up
|
||||
self.selection = match self.selection {
|
||||
Selection::EnterText => Selection::FilenameSearch,
|
||||
Selection::EnterText => Selection::AuthorsSearch,
|
||||
Selection::FuzzyOption => Selection::EnterText,
|
||||
Selection::CaseOption => Selection::FuzzyOption,
|
||||
Selection::MessageSearch => Selection::CaseOption,
|
||||
Selection::FilenameSearch => Selection::MessageSearch,
|
||||
Selection::AuthorsSearch => Selection::FilenameSearch,
|
||||
};
|
||||
} else {
|
||||
self.selection = match self.selection {
|
||||
@ -222,7 +244,8 @@ impl LogSearchPopupComponent {
|
||||
Selection::FuzzyOption => Selection::CaseOption,
|
||||
Selection::CaseOption => Selection::MessageSearch,
|
||||
Selection::MessageSearch => Selection::FilenameSearch,
|
||||
Selection::FilenameSearch => Selection::EnterText,
|
||||
Selection::FilenameSearch => Selection::AuthorsSearch,
|
||||
Selection::AuthorsSearch => Selection::EnterText,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user