mirror of
https://github.com/extrawurst/gitui.git
synced 2024-11-22 19:29:14 +03:00
Rust1.46 and nightly ci (#246)
This commit is contained in:
parent
53f333f4ca
commit
2401293b66
5
.github/workflows/ci.yml
vendored
5
.github/workflows/ci.yml
vendored
@ -14,8 +14,10 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
|
rust: [nightly, stable]
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
continue-on-error: ${{ matrix.rust == 'nightly' }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
@ -23,7 +25,8 @@ jobs:
|
|||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: stable
|
toolchain: ${{ matrix.rust }}
|
||||||
|
default: true
|
||||||
profile: minimal
|
profile: minimal
|
||||||
components: clippy
|
components: clippy
|
||||||
|
|
||||||
|
@ -111,7 +111,13 @@ pub fn unstage_hunk(
|
|||||||
|
|
||||||
let diff = get_diff_raw(&repo, &file_path, true, true)?;
|
let diff = get_diff_raw(&repo, &file_path, true, true)?;
|
||||||
|
|
||||||
assert_eq!(diff.deltas().len(), diff_count_positive);
|
if diff.deltas().len() != diff_count_positive {
|
||||||
|
return Err(Error::Generic(format!(
|
||||||
|
"hunk error: {}!={}",
|
||||||
|
diff.deltas().len(),
|
||||||
|
diff_count_positive
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
{
|
{
|
||||||
|
@ -124,7 +124,7 @@ impl CommandBar {
|
|||||||
self.refresh_list(self.width);
|
self.refresh_list(self.width);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn height(&self) -> u16 {
|
pub const fn height(&self) -> u16 {
|
||||||
if self.expandable && self.expanded {
|
if self.expandable && self.expanded {
|
||||||
self.lines
|
self.lines
|
||||||
} else {
|
} else {
|
||||||
|
@ -63,24 +63,28 @@ impl CommandInfo {
|
|||||||
order: 0,
|
order: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
pub const fn order(self, order: i8) -> Self {
|
pub const fn order(self, order: i8) -> Self {
|
||||||
let mut res = self;
|
let mut res = self;
|
||||||
res.order = order;
|
res.order = order;
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
pub const fn hidden(self) -> Self {
|
pub const fn hidden(self) -> Self {
|
||||||
let mut res = self;
|
let mut res = self;
|
||||||
res.quick_bar = false;
|
res.quick_bar = false;
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
pub fn print(&self, out: &mut String) {
|
pub fn print(&self, out: &mut String) {
|
||||||
out.push_str(&self.text.name);
|
out.push_str(&self.text.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
pub fn show_in_quickbar(&self) -> bool {
|
pub const fn show_in_quickbar(&self) -> bool {
|
||||||
self.quick_bar && self.available
|
self.quick_bar && self.available
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,11 +208,10 @@ impl CommitComponent {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = if let Some(amend) = self.amend {
|
let res =
|
||||||
|
self.amend.map_or(sync::commit(CWD, &msg), |amend| {
|
||||||
sync::amend(CWD, amend, &msg)
|
sync::amend(CWD, amend, &msg)
|
||||||
} else {
|
});
|
||||||
sync::commit(CWD, &msg)
|
|
||||||
};
|
|
||||||
if let Err(e) = res {
|
if let Err(e) = res {
|
||||||
log::error!("commit error: {}", &e);
|
log::error!("commit error: {}", &e);
|
||||||
self.queue.borrow_mut().push_back(
|
self.queue.borrow_mut().push_back(
|
||||||
|
@ -69,11 +69,8 @@ impl DetailsComponent {
|
|||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
self.tags.clear();
|
self.tags.clear();
|
||||||
|
|
||||||
self.data = if let Some(id) = id {
|
self.data =
|
||||||
sync::get_commit_details(CWD, id).ok()
|
id.and_then(|id| sync::get_commit_details(CWD, id).ok());
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
self.scroll_top.set(0);
|
self.scroll_top.set(0);
|
||||||
|
|
||||||
|
@ -252,13 +252,11 @@ impl CommitList {
|
|||||||
.take(height)
|
.take(height)
|
||||||
.enumerate()
|
.enumerate()
|
||||||
{
|
{
|
||||||
let tags = if let Some(tags) =
|
let tags = self
|
||||||
self.tags.as_ref().and_then(|t| t.get(&e.id))
|
.tags
|
||||||
{
|
.as_ref()
|
||||||
Some(tags.join(" "))
|
.and_then(|t| t.get(&e.id))
|
||||||
} else {
|
.map(|tags| tags.join(" "));
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
Self::add_entry(
|
Self::add_entry(
|
||||||
e,
|
e,
|
||||||
|
@ -38,13 +38,13 @@ enum Selection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Selection {
|
impl Selection {
|
||||||
fn get_start(&self) -> usize {
|
const fn get_start(&self) -> usize {
|
||||||
match self {
|
match self {
|
||||||
Self::Single(start) | Self::Multiple(start, _) => *start,
|
Self::Single(start) | Self::Multiple(start, _) => *start,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_end(&self) -> usize {
|
const fn get_end(&self) -> usize {
|
||||||
match self {
|
match self {
|
||||||
Self::Single(end) | Self::Multiple(_, end) => *end,
|
Self::Single(end) | Self::Multiple(_, end) => *end,
|
||||||
}
|
}
|
||||||
@ -447,7 +447,7 @@ impl DiffComponent {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hunk_visible(
|
const fn hunk_visible(
|
||||||
hunk_min: usize,
|
hunk_min: usize,
|
||||||
hunk_max: usize,
|
hunk_max: usize,
|
||||||
min: usize,
|
min: usize,
|
||||||
|
@ -113,14 +113,12 @@ impl FileTreeComponent {
|
|||||||
|
|
||||||
///
|
///
|
||||||
pub fn is_file_seleted(&self) -> bool {
|
pub fn is_file_seleted(&self) -> bool {
|
||||||
if let Some(item) = self.tree.selected_item() {
|
self.tree.selected_item().map_or(false, |item| {
|
||||||
match item.kind {
|
match item.kind {
|
||||||
FileTreeItemKind::File(_) => true,
|
FileTreeItemKind::File(_) => true,
|
||||||
FileTreeItemKind::Path(..) => false,
|
FileTreeItemKind::Path(..) => false,
|
||||||
}
|
}
|
||||||
} else {
|
})
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_selection(&mut self, dir: MoveSelection) -> bool {
|
fn move_selection(&mut self, dir: MoveSelection) -> bool {
|
||||||
@ -207,7 +205,7 @@ impl FileTreeComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn item_status_char(item_type: StatusItemType) -> char {
|
const fn item_status_char(item_type: StatusItemType) -> char {
|
||||||
match item_type {
|
match item_type {
|
||||||
StatusItemType::Modified => 'M',
|
StatusItemType::Modified => 'M',
|
||||||
StatusItemType::New => '+',
|
StatusItemType::New => '+',
|
||||||
|
@ -122,14 +122,11 @@ impl TextInputComponent {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let cursor_str = if let Some(pos) = self.next_char_position()
|
let cursor_str = self
|
||||||
{
|
.next_char_position()
|
||||||
&self.msg[self.cursor_position..pos]
|
|
||||||
} else {
|
|
||||||
// if the cursor is at the end of the msg
|
// if the cursor is at the end of the msg
|
||||||
// a whitespace is used to underline
|
// a whitespace is used to underline
|
||||||
" "
|
.map_or(" ", |pos| &self.msg[self.cursor_position..pos]);
|
||||||
};
|
|
||||||
|
|
||||||
if cursor_str == "\n" {
|
if cursor_str == "\n" {
|
||||||
txt.push(Text::styled(
|
txt.push(Text::styled(
|
||||||
|
@ -44,17 +44,16 @@ impl StatusTree {
|
|||||||
let last_selection_index = self.selection.unwrap_or(0);
|
let last_selection_index = self.selection.unwrap_or(0);
|
||||||
|
|
||||||
self.tree = FileTreeItems::new(list, &last_collapsed)?;
|
self.tree = FileTreeItems::new(list, &last_collapsed)?;
|
||||||
self.selection =
|
self.selection = last_selection.as_ref().map_or(
|
||||||
if let Some(ref last_selection) = last_selection {
|
self.tree.items().first().map(|_| 0),
|
||||||
|
|last_selection| {
|
||||||
self.find_last_selection(
|
self.find_last_selection(
|
||||||
last_selection,
|
last_selection,
|
||||||
last_selection_index,
|
last_selection_index,
|
||||||
)
|
)
|
||||||
.or_else(|| self.tree.items().first().map(|_| 0))
|
.or_else(|| self.tree.items().first().map(|_| 0))
|
||||||
} else {
|
},
|
||||||
// simply select first
|
);
|
||||||
self.tree.items().first().map(|_| 0)
|
|
||||||
};
|
|
||||||
|
|
||||||
self.update_visibility(None, 0, true);
|
self.update_visibility(None, 0, true);
|
||||||
|
|
||||||
@ -80,7 +79,7 @@ impl StatusTree {
|
|||||||
|
|
||||||
///
|
///
|
||||||
pub fn move_selection(&mut self, dir: MoveSelection) -> bool {
|
pub fn move_selection(&mut self, dir: MoveSelection) -> bool {
|
||||||
if let Some(selection) = self.selection {
|
self.selection.map_or(false, |selection| {
|
||||||
let selection_change = match dir {
|
let selection_change = match dir {
|
||||||
MoveSelection::Up => {
|
MoveSelection::Up => {
|
||||||
self.selection_updown(selection, true)
|
self.selection_updown(selection, true)
|
||||||
@ -102,9 +101,7 @@ impl StatusTree {
|
|||||||
self.selection = Some(selection_change.new_index);
|
self.selection = Some(selection_change.new_index);
|
||||||
|
|
||||||
changed_index || selection_change.changes
|
changed_index || selection_change.changes
|
||||||
} else {
|
})
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#![deny(clippy::panic)]
|
#![deny(clippy::panic)]
|
||||||
#![allow(clippy::module_name_repetitions)]
|
#![allow(clippy::module_name_repetitions)]
|
||||||
#![allow(clippy::multiple_crate_versions)]
|
#![allow(clippy::multiple_crate_versions)]
|
||||||
|
#![warn(clippy::missing_const_for_fn)]
|
||||||
|
|
||||||
mod app;
|
mod app;
|
||||||
mod cmdbar;
|
mod cmdbar;
|
||||||
|
@ -158,15 +158,7 @@ impl Revlog {
|
|||||||
let tags = self.list.tags();
|
let tags = self.list.tags();
|
||||||
|
|
||||||
commit.and_then(|commit| {
|
commit.and_then(|commit| {
|
||||||
if let Some(tags) = tags {
|
tags.and_then(|tags| tags.get(&commit).cloned())
|
||||||
if let Some(tags) = tags.get(&commit) {
|
|
||||||
Some(tags.clone())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -213,28 +205,32 @@ impl Component for Revlog {
|
|||||||
self.update()?;
|
self.update()?;
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
} else if k == self.key_config.log_tag_commit {
|
} else if k == self.key_config.log_tag_commit {
|
||||||
return if let Some(id) = self.selected_commit() {
|
return self.selected_commit().map_or(
|
||||||
self.queue
|
Ok(false),
|
||||||
.borrow_mut()
|
|id| {
|
||||||
.push_back(InternalEvent::TagCommit(id));
|
self.queue.borrow_mut().push_back(
|
||||||
|
InternalEvent::TagCommit(id),
|
||||||
|
);
|
||||||
Ok(true)
|
Ok(true)
|
||||||
} else {
|
},
|
||||||
Ok(false)
|
);
|
||||||
};
|
|
||||||
} else if k == self.key_config.focus_right
|
} else if k == self.key_config.focus_right
|
||||||
&& self.commit_details.is_visible()
|
&& self.commit_details.is_visible()
|
||||||
{
|
{
|
||||||
return if let Some(id) = self.selected_commit() {
|
return self.selected_commit().map_or(
|
||||||
|
Ok(false),
|
||||||
|
|id| {
|
||||||
self.queue.borrow_mut().push_back(
|
self.queue.borrow_mut().push_back(
|
||||||
InternalEvent::InspectCommit(
|
InternalEvent::InspectCommit(
|
||||||
id,
|
id,
|
||||||
self.selected_commit_tags(&Some(id)),
|
self.selected_commit_tags(&Some(
|
||||||
|
id,
|
||||||
|
)),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
Ok(true)
|
Ok(true)
|
||||||
} else {
|
},
|
||||||
Ok(false)
|
);
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,11 @@ impl Theme {
|
|||||||
self.apply_select(style, selected)
|
self.apply_select(style, selected)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_select(&self, style: Style, selected: bool) -> Style {
|
const fn apply_select(
|
||||||
|
&self,
|
||||||
|
style: Style,
|
||||||
|
selected: bool,
|
||||||
|
) -> Style {
|
||||||
if selected {
|
if selected {
|
||||||
style.bg(self.selection_bg)
|
style.bg(self.selection_bg)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user