Skip to content

Commit 2401293

Browse files
author
Stephan Dilly
authored
Rust1.46 and nightly ci (#246)
1 parent 53f333f commit 2401293

File tree

14 files changed

+74
-74
lines changed

14 files changed

+74
-74
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
os: [ubuntu-latest, macos-latest, windows-latest]
17+
rust: [nightly, stable]
1718

1819
runs-on: ${{ matrix.os }}
20+
continue-on-error: ${{ matrix.rust == 'nightly' }}
1921

2022
steps:
2123
- uses: actions/checkout@v2
2224

2325
- name: Install Rust
2426
uses: actions-rs/toolchain@v1
2527
with:
26-
toolchain: stable
28+
toolchain: ${{ matrix.rust }}
29+
default: true
2730
profile: minimal
2831
components: clippy
2932

asyncgit/src/sync/hunks.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,13 @@ pub fn unstage_hunk(
111111

112112
let diff = get_diff_raw(&repo, &file_path, true, true)?;
113113

114-
assert_eq!(diff.deltas().len(), diff_count_positive);
114+
if diff.deltas().len() != diff_count_positive {
115+
return Err(Error::Generic(format!(
116+
"hunk error: {}!={}",
117+
diff.deltas().len(),
118+
diff_count_positive
119+
)));
120+
}
115121

116122
let mut count = 0;
117123
{

src/cmdbar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl CommandBar {
124124
self.refresh_list(self.width);
125125
}
126126

127-
pub fn height(&self) -> u16 {
127+
pub const fn height(&self) -> u16 {
128128
if self.expandable && self.expanded {
129129
self.lines
130130
} else {

src/components/command.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,28 @@ impl CommandInfo {
6363
order: 0,
6464
}
6565
}
66+
6667
///
6768
pub const fn order(self, order: i8) -> Self {
6869
let mut res = self;
6970
res.order = order;
7071
res
7172
}
73+
7274
///
7375
pub const fn hidden(self) -> Self {
7476
let mut res = self;
7577
res.quick_bar = false;
7678
res
7779
}
80+
7881
///
7982
pub fn print(&self, out: &mut String) {
8083
out.push_str(&self.text.name);
8184
}
85+
8286
///
83-
pub fn show_in_quickbar(&self) -> bool {
87+
pub const fn show_in_quickbar(&self) -> bool {
8488
self.quick_bar && self.available
8589
}
8690
}

src/components/commit.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,10 @@ impl CommitComponent {
208208
return Ok(());
209209
}
210210

211-
let res = if let Some(amend) = self.amend {
212-
sync::amend(CWD, amend, &msg)
213-
} else {
214-
sync::commit(CWD, &msg)
215-
};
211+
let res =
212+
self.amend.map_or(sync::commit(CWD, &msg), |amend| {
213+
sync::amend(CWD, amend, &msg)
214+
});
216215
if let Err(e) = res {
217216
log::error!("commit error: {}", &e);
218217
self.queue.borrow_mut().push_back(

src/components/commit_details/details.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,8 @@ impl DetailsComponent {
6969
) -> Result<()> {
7070
self.tags.clear();
7171

72-
self.data = if let Some(id) = id {
73-
sync::get_commit_details(CWD, id).ok()
74-
} else {
75-
None
76-
};
72+
self.data =
73+
id.and_then(|id| sync::get_commit_details(CWD, id).ok());
7774

7875
self.scroll_top.set(0);
7976

src/components/commitlist.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,11 @@ impl CommitList {
252252
.take(height)
253253
.enumerate()
254254
{
255-
let tags = if let Some(tags) =
256-
self.tags.as_ref().and_then(|t| t.get(&e.id))
257-
{
258-
Some(tags.join(" "))
259-
} else {
260-
None
261-
};
255+
let tags = self
256+
.tags
257+
.as_ref()
258+
.and_then(|t| t.get(&e.id))
259+
.map(|tags| tags.join(" "));
262260

263261
Self::add_entry(
264262
e,

src/components/diff.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ enum Selection {
3838
}
3939

4040
impl Selection {
41-
fn get_start(&self) -> usize {
41+
const fn get_start(&self) -> usize {
4242
match self {
4343
Self::Single(start) | Self::Multiple(start, _) => *start,
4444
}
4545
}
4646

47-
fn get_end(&self) -> usize {
47+
const fn get_end(&self) -> usize {
4848
match self {
4949
Self::Single(end) | Self::Multiple(_, end) => *end,
5050
}
@@ -447,7 +447,7 @@ impl DiffComponent {
447447
));
448448
}
449449

450-
fn hunk_visible(
450+
const fn hunk_visible(
451451
hunk_min: usize,
452452
hunk_max: usize,
453453
min: usize,

src/components/filetree.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,12 @@ impl FileTreeComponent {
113113

114114
///
115115
pub fn is_file_seleted(&self) -> bool {
116-
if let Some(item) = self.tree.selected_item() {
116+
self.tree.selected_item().map_or(false, |item| {
117117
match item.kind {
118118
FileTreeItemKind::File(_) => true,
119119
FileTreeItemKind::Path(..) => false,
120120
}
121-
} else {
122-
false
123-
}
121+
})
124122
}
125123

126124
fn move_selection(&mut self, dir: MoveSelection) -> bool {
@@ -207,7 +205,7 @@ impl FileTreeComponent {
207205
}
208206
}
209207

210-
fn item_status_char(item_type: StatusItemType) -> char {
208+
const fn item_status_char(item_type: StatusItemType) -> char {
211209
match item_type {
212210
StatusItemType::Modified => 'M',
213211
StatusItemType::New => '+',

src/components/textinput.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,11 @@ impl TextInputComponent {
122122
));
123123
}
124124

125-
let cursor_str = if let Some(pos) = self.next_char_position()
126-
{
127-
&self.msg[self.cursor_position..pos]
128-
} else {
125+
let cursor_str = self
126+
.next_char_position()
129127
// if the cursor is at the end of the msg
130128
// a whitespace is used to underline
131-
" "
132-
};
129+
.map_or(" ", |pos| &self.msg[self.cursor_position..pos]);
133130

134131
if cursor_str == "\n" {
135132
txt.push(Text::styled(

0 commit comments

Comments
 (0)