mirror of
https://github.com/starship/starship.git
synced 2025-06-25 12:22:50 +02:00
chore: fix upcoming rust 1.77 clippy issues and chrono deprecations (#5850)
This commit is contained in:
parent
49575e5a55
commit
0e334e3e6c
@ -38,9 +38,9 @@ pub struct Context<'a> {
|
|||||||
/// The current working directory that starship is being called in.
|
/// The current working directory that starship is being called in.
|
||||||
pub current_dir: PathBuf,
|
pub current_dir: PathBuf,
|
||||||
|
|
||||||
/// A logical directory path which should represent the same directory as current_dir,
|
/// A logical directory path which should represent the same directory as `current_dir`,
|
||||||
/// though may appear different.
|
/// though may appear different.
|
||||||
/// E.g. when navigating to a PSDrive in PowerShell, or a path without symlinks resolved.
|
/// E.g. when navigating to a `PSDrive` in `PowerShell`, or a path without symlinks resolved.
|
||||||
pub logical_dir: PathBuf,
|
pub logical_dir: PathBuf,
|
||||||
|
|
||||||
/// A struct containing directory contents in a lookup-optimized format.
|
/// A struct containing directory contents in a lookup-optimized format.
|
||||||
@ -61,10 +61,10 @@ pub struct Context<'a> {
|
|||||||
/// Width of terminal, or zero if width cannot be detected.
|
/// Width of terminal, or zero if width cannot be detected.
|
||||||
pub width: usize,
|
pub width: usize,
|
||||||
|
|
||||||
/// A HashMap of environment variable mocks
|
/// A `HashMap` of environment variable mocks
|
||||||
pub env: Env<'a>,
|
pub env: Env<'a>,
|
||||||
|
|
||||||
/// A HashMap of command mocks
|
/// A `HashMap` of command mocks
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub cmd: HashMap<&'a str, Option<CommandOutput>>,
|
pub cmd: HashMap<&'a str, Option<CommandOutput>>,
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ use std::ffi::OsString;
|
|||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Env<'a> {
|
pub struct Env<'a> {
|
||||||
/// A HashMap of environment variable mocks
|
/// A `HashMap` of environment variable mocks
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub env: HashMap<&'a str, String>,
|
pub env: HashMap<&'a str, String>,
|
||||||
|
|
||||||
|
@ -684,15 +684,12 @@ credential_process = /opt/bin/awscreds-retriever
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn expiration_date_set() {
|
fn expiration_date_set() {
|
||||||
use chrono::{DateTime, NaiveDateTime, SecondsFormat, Utc};
|
use chrono::{DateTime, SecondsFormat, Utc};
|
||||||
|
|
||||||
let expiration_env_vars = ["AWS_SESSION_EXPIRATION", "AWS_CREDENTIAL_EXPIRATION"];
|
let expiration_env_vars = ["AWS_SESSION_EXPIRATION", "AWS_CREDENTIAL_EXPIRATION"];
|
||||||
expiration_env_vars.iter().for_each(|env_var| {
|
expiration_env_vars.iter().for_each(|env_var| {
|
||||||
let now_plus_half_hour: DateTime<Utc> = DateTime::from_naive_utc_and_offset(
|
let now_plus_half_hour: DateTime<Utc> =
|
||||||
NaiveDateTime::from_timestamp_opt(chrono::Local::now().timestamp() + 1800, 0)
|
DateTime::from_timestamp(chrono::Local::now().timestamp() + 1800, 0).unwrap();
|
||||||
.unwrap(),
|
|
||||||
Utc,
|
|
||||||
);
|
|
||||||
|
|
||||||
let actual = ModuleRenderer::new("aws")
|
let actual = ModuleRenderer::new("aws")
|
||||||
.env("AWS_PROFILE", "astronauts")
|
.env("AWS_PROFILE", "astronauts")
|
||||||
@ -727,12 +724,10 @@ credential_process = /opt/bin/awscreds-retriever
|
|||||||
let credentials_path = dir.path().join("credentials");
|
let credentials_path = dir.path().join("credentials");
|
||||||
let mut file = File::create(&credentials_path)?;
|
let mut file = File::create(&credentials_path)?;
|
||||||
|
|
||||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
|
|
||||||
let now_plus_half_hour: DateTime<Utc> = DateTime::from_naive_utc_and_offset(
|
let now_plus_half_hour: DateTime<Utc> =
|
||||||
NaiveDateTime::from_timestamp_opt(chrono::Local::now().timestamp() + 1800, 0).unwrap(),
|
DateTime::from_timestamp(chrono::Local::now().timestamp() + 1800, 0).unwrap();
|
||||||
Utc,
|
|
||||||
);
|
|
||||||
|
|
||||||
let expiration_date = now_plus_half_hour.to_rfc3339_opts(chrono::SecondsFormat::Secs, true);
|
let expiration_date = now_plus_half_hour.to_rfc3339_opts(chrono::SecondsFormat::Secs, true);
|
||||||
|
|
||||||
@ -800,12 +795,10 @@ aws_secret_access_key=dummy
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn expiration_date_set_expired() {
|
fn expiration_date_set_expired() {
|
||||||
use chrono::{DateTime, NaiveDateTime, SecondsFormat, Utc};
|
use chrono::{DateTime, SecondsFormat, Utc};
|
||||||
|
|
||||||
let now: DateTime<Utc> = DateTime::from_naive_utc_and_offset(
|
let now: DateTime<Utc> =
|
||||||
NaiveDateTime::from_timestamp_opt(chrono::Local::now().timestamp() - 1800, 0).unwrap(),
|
DateTime::from_timestamp(chrono::Local::now().timestamp() - 1800, 0).unwrap();
|
||||||
Utc,
|
|
||||||
);
|
|
||||||
|
|
||||||
let symbol = "!!!";
|
let symbol = "!!!";
|
||||||
|
|
||||||
|
@ -70,7 +70,9 @@ impl<'a> ModuleRenderer<'a> {
|
|||||||
T: Into<PathBuf>,
|
T: Into<PathBuf>,
|
||||||
{
|
{
|
||||||
self.context.current_dir = path.into();
|
self.context.current_dir = path.into();
|
||||||
self.context.logical_dir = self.context.current_dir.clone();
|
self.context
|
||||||
|
.logical_dir
|
||||||
|
.clone_from(&self.context.current_dir);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,6 +186,7 @@ pub fn fixture_repo(provider: FixtureProvider) -> io::Result<TempDir> {
|
|||||||
fs::OpenOptions::new()
|
fs::OpenOptions::new()
|
||||||
.create(true)
|
.create(true)
|
||||||
.write(true)
|
.write(true)
|
||||||
|
.truncate(false)
|
||||||
.open(path.path().join(checkout_db))?
|
.open(path.path().join(checkout_db))?
|
||||||
.sync_all()?;
|
.sync_all()?;
|
||||||
Ok(path)
|
Ok(path)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user