Skip to content

Commit f14578d

Browse files
committed
do shell expansion for commit.template
1 parent 9fed46c commit f14578d

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424
* fix commit dialog char count for multibyte characters ([#1726](https://github.com/extrawurst/gitui/issues/1726))
2525
* fix wrong hit highlighting in fuzzy find popup [[@UUGTech](https://github.com/UUGTech)] ([#1731](https://github.com/extrawurst/gitui/pull/1731))
2626
* fix symlink support for configuration files [[@TheBlackSheep3](https://github.com/TheBlackSheep3)] ([#1751](https://github.com/extrawurst/gitui/issues/1751))
27+
* expand `~` in `commit.template` ([#1745](https://github.com/extrawurst/gitui/pull/1745))
2728

2829
## [0.23.0] - 2022-06-19
2930

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ ron = "0.8"
4646
scopeguard = "1.2"
4747
scopetime = { path = "./scopetime", version = "0.1" }
4848
serde = "1.0"
49+
shellexpand = "3.1"
4950
simplelog = { version = "0.12", default-features = false }
5051
struct-patch = "0.2"
5152
syntect = { version = "5.0", default-features = false, features = ["parsing", "default-syntaxes", "default-themes", "html"] }

src/components/commit.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ use ratatui::{
3030
use std::{
3131
fs::{read_to_string, File},
3232
io::{Read, Write},
33+
path::PathBuf,
34+
str::FromStr,
3335
};
3436

3537
enum CommitResult {
@@ -412,10 +414,17 @@ impl CommitComponent {
412414
})
413415
.ok()
414416
.flatten()
417+
.and_then(|path| {
418+
shellexpand::full(path.as_str())
419+
.ok()
420+
.and_then(|path| {
421+
PathBuf::from_str(path.as_ref()).ok()
422+
})
423+
})
415424
.and_then(|path| {
416425
read_to_string(&path)
417426
.map_err(|e| {
418-
log::error!("read commit.template failed: {e} (path: '{path}')");
427+
log::error!("read commit.template failed: {e} (path: '{:?}')",path);
419428
e
420429
})
421430
.ok()

0 commit comments

Comments
 (0)