repository search now tries to match the filename set by the REMUX_REPO_NAME environment variable

This commit is contained in:
Valerie Wolfe 2024-07-17 09:15:11 -04:00
parent b7b893d55c
commit 449c460bbb
4 changed files with 7 additions and 3 deletions

View file

@ -135,6 +135,9 @@ Default: '>'
.It Ev REMUX_NEW_WINDOW
Provides a default windows name when creating a new session. Unused if empty.
Default: (unset)
.It Ev REMUX_REPO_FILE
The filename to match on when trying to find the root of a repository.
Default: '.git'
.El
.Sh EXIT STATUS
.Bl -tag -Width Ds

View file

@ -5,6 +5,7 @@ pub type EnvVar = (&'static str, &'static str);
pub static ATTACH_SYMBOL: EnvVar = ("REMUX_ATTACH_SYMBOL", "*");
pub static CURRENT_SYMBOL: EnvVar = ("REMUX_CURRENT_SYMBOL", ">");
pub static NEW_WINDOW_NAME: EnvVar = ("REMUX_NEW_WINDOW", "");
pub static REPO_FILE: EnvVar = ("REMUX_REPO_FILE", ".git");
pub static TMUX: &str = "TMUX";

View file

@ -6,7 +6,7 @@ use std::{
use pico_args::Arguments;
use crate::{
env::TMUX,
env::{ env_var, REPO_FILE, TMUX },
error,
flag::Flags,
util::{ find, session_name }
@ -82,7 +82,7 @@ pub struct Repository {
impl Repository {
pub fn find() -> Option<Repository> {
let path = find(".git", env::current_dir().unwrap());
let path = find(&env_var(REPO_FILE), env::current_dir().unwrap());
if let Some(path) = path {
let name = path.file_name().unwrap().to_string_lossy().to_string();
let inner = Repository {

View file

@ -51,7 +51,7 @@ pub fn terminal_enforce() {
}
/// recursively propagate up directories to find a child
pub fn find(target: &'static str, path: PathBuf) -> Option<PathBuf> {
pub fn find(target: &str, path: PathBuf) -> Option<PathBuf> {
if path.join(target).exists() { return Some(path); }
let parent = path.parent();