Skip to content

Commit

Permalink
Update rust and fix lint (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthauck authored Oct 18, 2023
1 parent f7df6a0 commit dcbddae
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ RUN apt-get update \
&& rm -fr /var/lib/apt/lists/

ENV PATH $PATH:/root/.cargo/bin
ENV RUST_VERSION 1.71.1
ENV RUST_VERSION 1.73.0

# install rust
RUN curl -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain "$RUST_VERSION" \
Expand Down
10 changes: 5 additions & 5 deletions lib/src/github/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ impl GithubSession {
) -> Result<GithubSession> {
let mut headers = reqwest::header::HeaderMap::new();

let accept_headers = vec![
let accept_headers = [
// standard header
"application/vnd.github.v3+json",
// timeline api
Expand Down Expand Up @@ -460,7 +460,7 @@ impl GithubSession {
}
}

pull_requests.extend(next_prs.into_iter());
pull_requests.extend(next_prs);
page += 1;
}
Ok(pull_requests)
Expand Down Expand Up @@ -652,7 +652,7 @@ impl Session for GithubSession {
break;
}

result.extend(next.into_iter());
result.extend(next);
page += 1;
}

Expand Down Expand Up @@ -885,7 +885,7 @@ impl Session for GithubSession {
break;
}

events.extend(next_events.into_iter());
events.extend(next_events);
page += 1;
}

Expand Down Expand Up @@ -1037,7 +1037,7 @@ impl Session for GithubSession {

let done = results.iter().any(|d| d.guid == guid);

result.extend(results.into_iter());
result.extend(results);

if done {
break;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/github/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ impl PullRequest {
pub fn all_reviewers(&self) -> Vec<User> {
let mut reviewers = vec![];
if let Some(ref requested_reviewers) = self.requested_reviewers {
reviewers.extend(requested_reviewers.clone().into_iter());
reviewers.extend(requested_reviewers.clone());
}

if let Some(ref reviews) = self.reviews {
Expand Down
21 changes: 10 additions & 11 deletions lib/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,23 @@ impl Eq for Version {}

impl PartialOrd for Version {
fn partial_cmp(&self, other: &Version) -> Option<Ordering> {
Some(self.cmp(other))
}
}

impl Ord for Version {
fn cmp(&self, other: &Version) -> Ordering {
// Note: this is always going to be at least 3.
let min_len = cmp::min(self.parts.len(), other.parts.len());
for i in 0..min_len {
let result = self.parts[i].cmp(&other.parts[i]);
if !result.is_eq() {
return Some(result);
return result;
}
}

if self.parts.len() == other.parts.len() {
return Some(Ordering::Equal);
return Ordering::Equal;
}

// if all else is equal, but one of the Versions has more elements,
Expand All @@ -84,18 +90,11 @@ impl PartialOrd for Version {
}
for part in longer_parts.iter().skip(min_len) {
if *part != 0 {
return Some(nonzero_answer);
return nonzero_answer;
}
}

Some(Ordering::Equal)
}
}

impl Ord for Version {
fn cmp(&self, other: &Version) -> Ordering {
// we never return None
self.partial_cmp(other).unwrap()
Ordering::Equal
}
}

Expand Down
4 changes: 2 additions & 2 deletions octobot/src/server/github_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,12 +514,12 @@ impl GithubEventHandler {
for t in teams {
let team_members = self.team_members_cache.get(repo, t.id);
if let Some(team_members) = team_members {
participants.extend(team_members.into_iter());
participants.extend(team_members);
} else {
let team_members = self.github_session.get_team_members(repo, t.id).await;
match team_members {
Ok(m) => {
participants.extend(m.clone().into_iter());
participants.extend(m.clone());
self.team_members_cache.insert(repo, t.id, m);
}
Err(e) => {
Expand Down
2 changes: 1 addition & 1 deletion ops/src/pr_merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ fn do_cherry_pick(

let mut args = vec!["-c", "merge.renameLimit=999999"];
args.extend(user_opts.iter());
args.extend(vec!["cherry-pick", "--allow-empty"].iter());
args.extend(["cherry-pick", "--allow-empty"].iter());
args.extend(opts);
args.push(commit_hash);

Expand Down

0 comments on commit dcbddae

Please sign in to comment.