Skip to content

Commit fd5ff21

Browse files
authored
Merge branch 'master' into feat/checkout_method
2 parents 959f336 + ec65b37 commit fd5ff21

File tree

5 files changed

+48
-58
lines changed

5 files changed

+48
-58
lines changed

asyncgit/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ It wraps libraries like git2 and gix.
1515
unused_must_use,
1616
dead_code,
1717
unstable_name_collisions,
18-
unused_assignments
18+
unused_assignments,
19+
deprecated
1920
)]
2021
#![deny(clippy::all, clippy::perf, clippy::nursery, clippy::pedantic)]
2122
#![deny(

asyncgit/src/sync/logwalker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl<'a> LogWalkerWithoutFilter<'a> {
133133
// reason this is 2^14, so benchmarking might reveal that there’s better values.
134134
repo.object_cache_size_if_unset(2_usize.pow(14));
135135

136-
let commit = repo.head()?.peel_to_commit_in_place()?;
136+
let commit = repo.head()?.peel_to_commit()?;
137137

138138
let tips = [commit.id];
139139

asyncgit/src/sync/remotes/mod.rs

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -369,12 +369,8 @@ mod tests {
369369
let (remote_dir, _remote) = repo_init().unwrap();
370370
let remote_path = remote_dir.path().to_str().unwrap();
371371
let (repo_dir, _repo) = repo_clone(remote_path).unwrap();
372-
let repo_path: &RepoPath = &repo_dir
373-
.into_path()
374-
.as_os_str()
375-
.to_str()
376-
.unwrap()
377-
.into();
372+
let repo_path: &RepoPath =
373+
&repo_dir.keep().as_os_str().to_str().unwrap().into();
378374

379375
let remotes = get_remotes(repo_path).unwrap();
380376

@@ -388,12 +384,8 @@ mod tests {
388384
let (remote_dir, _remote) = repo_init().unwrap();
389385
let remote_path = remote_dir.path().to_str().unwrap();
390386
let (repo_dir, _repo) = repo_clone(remote_path).unwrap();
391-
let repo_path: &RepoPath = &repo_dir
392-
.into_path()
393-
.as_os_str()
394-
.to_str()
395-
.unwrap()
396-
.into();
387+
let repo_path: &RepoPath =
388+
&repo_dir.keep().as_os_str().to_str().unwrap().into();
397389

398390
debug_cmd_print(
399391
repo_path,
@@ -418,12 +410,8 @@ mod tests {
418410
let (remote_dir, _remote) = repo_init().unwrap();
419411
let remote_path = remote_dir.path().to_str().unwrap();
420412
let (repo_dir, _repo) = repo_clone(remote_path).unwrap();
421-
let repo_path: &RepoPath = &repo_dir
422-
.into_path()
423-
.as_os_str()
424-
.to_str()
425-
.unwrap()
426-
.into();
413+
let repo_path: &RepoPath =
414+
&repo_dir.keep().as_os_str().to_str().unwrap().into();
427415

428416
debug_cmd_print(
429417
repo_path,
@@ -454,12 +442,8 @@ mod tests {
454442
let (remote_dir, _remote) = repo_init().unwrap();
455443
let remote_path = remote_dir.path().to_str().unwrap();
456444
let (repo_dir, _repo) = repo_clone(remote_path).unwrap();
457-
let repo_path: &RepoPath = &repo_dir
458-
.into_path()
459-
.as_os_str()
460-
.to_str()
461-
.unwrap()
462-
.into();
445+
let repo_path: &RepoPath =
446+
&repo_dir.keep().as_os_str().to_str().unwrap().into();
463447

464448
debug_cmd_print(
465449
repo_path,
@@ -494,12 +478,8 @@ mod tests {
494478
let (remote_dir, _remote) = repo_init().unwrap();
495479
let remote_path = remote_dir.path().to_str().unwrap();
496480
let (repo_dir, repo) = repo_clone(remote_path).unwrap();
497-
let repo_path: &RepoPath = &repo_dir
498-
.into_path()
499-
.as_os_str()
500-
.to_str()
501-
.unwrap()
502-
.into();
481+
let repo_path: &RepoPath =
482+
&repo_dir.keep().as_os_str().to_str().unwrap().into();
503483

504484
debug_cmd_print(
505485
repo_path,
@@ -530,12 +510,8 @@ mod tests {
530510
let (remote_dir, _remote) = repo_init().unwrap();
531511
let remote_path = remote_dir.path().to_str().unwrap();
532512
let (repo_dir, repo) = repo_clone(remote_path).unwrap();
533-
let repo_path: &RepoPath = &repo_dir
534-
.into_path()
535-
.as_os_str()
536-
.to_str()
537-
.unwrap()
538-
.into();
513+
let repo_path: &RepoPath =
514+
&repo_dir.keep().as_os_str().to_str().unwrap().into();
539515

540516
debug_cmd_print(
541517
repo_path,

asyncgit/src/sync/submodules.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ mod tests {
182182
s.add_finalize().unwrap();
183183
}
184184

185-
let repo_p = RepoPath::Path(dir.into_path());
185+
let repo_p = RepoPath::Path(dir.keep());
186186
let subs = get_submodules(&repo_p).unwrap();
187187

188188
assert_eq!(subs.len(), 1);

src/args.rs

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ use std::{
1212
path::PathBuf,
1313
};
1414

15+
const BUG_REPORT_FLAG_ID: &str = "bugreport";
16+
const LOG_FILE_FLAG_ID: &str = "logfile";
17+
const LOGGING_FLAG_ID: &str = "logging";
18+
const THEME_FLAG_ID: &str = "theme";
19+
const WORKDIR_FLAG_ID: &str = "workdir";
20+
const GIT_DIR_FLAG_ID: &str = "directory";
21+
const WATCHER_FLAG_ID: &str = "watcher";
22+
const DEFAULT_THEME: &str = "theme.ron";
23+
const DEFAULT_GIT_DIR: &str = ".";
24+
1525
pub struct CliArgs {
1626
pub theme: PathBuf,
1727
pub repo_path: RepoPath,
@@ -23,20 +33,23 @@ pub fn process_cmdline() -> Result<CliArgs> {
2333

2434
let arg_matches = app.get_matches();
2535

26-
if arg_matches.get_flag("bugreport") {
36+
if arg_matches.get_flag(BUG_REPORT_FLAG_ID) {
2737
bug_report::generate_bugreport();
2838
std::process::exit(0);
2939
}
30-
if arg_matches.get_flag("logging") {
31-
let logfile = arg_matches.get_one::<String>("logfile");
40+
if arg_matches.get_flag(LOGGING_FLAG_ID) {
41+
let logfile = arg_matches.get_one::<String>(LOG_FILE_FLAG_ID);
3242
setup_logging(logfile.map(PathBuf::from))?;
3343
}
3444

35-
let workdir =
36-
arg_matches.get_one::<String>("workdir").map(PathBuf::from);
37-
let gitdir = arg_matches
38-
.get_one::<String>("directory")
39-
.map_or_else(|| PathBuf::from("."), PathBuf::from);
45+
let workdir = arg_matches
46+
.get_one::<String>(WORKDIR_FLAG_ID)
47+
.map(PathBuf::from);
48+
let gitdir =
49+
arg_matches.get_one::<String>(GIT_DIR_FLAG_ID).map_or_else(
50+
|| PathBuf::from(DEFAULT_GIT_DIR),
51+
PathBuf::from,
52+
);
4053

4154
let repo_path = if let Some(w) = workdir {
4255
RepoPath::Workdir { gitdir, workdir: w }
@@ -45,8 +58,8 @@ pub fn process_cmdline() -> Result<CliArgs> {
4558
};
4659

4760
let arg_theme = arg_matches
48-
.get_one::<String>("theme")
49-
.map_or_else(|| PathBuf::from("theme.ron"), PathBuf::from);
61+
.get_one::<String>(THEME_FLAG_ID)
62+
.map_or_else(|| PathBuf::from(DEFAULT_THEME), PathBuf::from);
5063

5164
let confpath = get_app_config_path()?;
5265
fs::create_dir_all(&confpath).with_context(|| {
@@ -58,7 +71,7 @@ pub fn process_cmdline() -> Result<CliArgs> {
5871
let theme = confpath.join(arg_theme);
5972

6073
let notify_watcher: bool =
61-
*arg_matches.get_one("watcher").unwrap_or(&false);
74+
*arg_matches.get_one(WATCHER_FLAG_ID).unwrap_or(&false);
6275

6376
Ok(CliArgs {
6477
theme,
@@ -84,48 +97,48 @@ fn app() -> ClapApp {
8497
",
8598
)
8699
.arg(
87-
Arg::new("theme")
100+
Arg::new(THEME_FLAG_ID)
88101
.help("Set color theme filename loaded from config directory")
89102
.short('t')
90103
.long("theme")
91104
.value_name("THEME_FILE")
92-
.default_value("theme.ron")
105+
.default_value(DEFAULT_THEME)
93106
.num_args(1),
94107
)
95108
.arg(
96-
Arg::new("logging")
109+
Arg::new(LOGGING_FLAG_ID)
97110
.help("Store logging output into a file (in the cache directory by default)")
98111
.short('l')
99112
.long("logging")
100113
.default_value_if("logfile", ArgPredicate::IsPresent, "true")
101114
.action(clap::ArgAction::SetTrue),
102115
)
103-
.arg(Arg::new("logfile")
116+
.arg(Arg::new(LOG_FILE_FLAG_ID)
104117
.help("Store logging output into the specified file (implies --logging)")
105118
.long("logfile")
106119
.value_name("LOG_FILE"))
107120
.arg(
108-
Arg::new("watcher")
121+
Arg::new(WATCHER_FLAG_ID)
109122
.help("Use notify-based file system watcher instead of tick-based update. This is more performant, but can cause issues on some platforms. See https://github.com/gitui-org/gitui/blob/master/FAQ.md#watcher for details.")
110123
.long("watcher")
111124
.action(clap::ArgAction::SetTrue),
112125
)
113126
.arg(
114-
Arg::new("bugreport")
127+
Arg::new(BUG_REPORT_FLAG_ID)
115128
.help("Generate a bug report")
116129
.long("bugreport")
117130
.action(clap::ArgAction::SetTrue),
118131
)
119132
.arg(
120-
Arg::new("directory")
133+
Arg::new(GIT_DIR_FLAG_ID)
121134
.help("Set the git directory")
122135
.short('d')
123136
.long("directory")
124137
.env("GIT_DIR")
125138
.num_args(1),
126139
)
127140
.arg(
128-
Arg::new("workdir")
141+
Arg::new(WORKDIR_FLAG_ID)
129142
.help("Set the working directory")
130143
.short('w')
131144
.long("workdir")

0 commit comments

Comments
 (0)