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