Skip to content

Commit

Permalink
fix(main/starship): backport username detection fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TomJo2000 committed Dec 14, 2024
1 parent 7d7ff62 commit b046a81
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions packages/starship/6342-fix-username.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
From abad5e3de2d680f905d4b95349b1d6926cea36c2 Mon Sep 17 00:00:00 2001
From: David Knaack <[email protected]>
Date: Mon, 21 Oct 2024 19:10:17 +0200
Subject: [PATCH] fix(username): avoid using `whoami` on android

Closes #6340

Co-Authored-By: AminurAlam <[email protected]>
---
src/modules/username.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/modules/username.rs b/src/modules/username.rs
index 8ba3509e44b9..59d6f8330f51 100644
--- a/src/modules/username.rs
+++ b/src/modules/username.rs
@@ -19,13 +19,13 @@ const USERNAME_ENV_VAR: &str = "USERNAME";
/// Does not display the username:
/// - If the option `username.detect_env_vars` is set with a negated environment variable [A]
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
- #[cfg(not(test))]
+ #[cfg(not(any(test, target_os = "android")))]
let mut username = whoami::fallible::username()
.inspect_err(|e| log::debug!("Failed to get username {e:?}"))
.ok()
.or_else(|| context.get_env(USERNAME_ENV_VAR))?;

- #[cfg(test)]
+ #[cfg(any(test, target_os = "android"))]
let mut username = context.get_env(USERNAME_ENV_VAR)?;

let mut module = context.new_module("username");
2 changes: 1 addition & 1 deletion packages/starship/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="A minimal, blazing fast, and extremely customizable prom
TERMUX_PKG_LICENSE="ISC"
TERMUX_PKG_MAINTAINER="Joshua Kahn @TomJo2000"
TERMUX_PKG_VERSION="1.21.1"
TERMUX_PKG_REVISION=1
TERMUX_PKG_REVISION=2
TERMUX_PKG_SRCURL=https://github.com/starship/starship/archive/refs/tags/v${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=f543dfa3229441ca2a55b8a625ce4bad5756a896378b019f4d0f0e00cf34dcc8
TERMUX_PKG_AUTO_UPDATE=true
Expand Down

0 comments on commit b046a81

Please sign in to comment.