Skip to content

Commit e2144fc

Browse files
committed
Added $homedrive to Win config path
1 parent c649f8b commit e2144fc

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,24 @@ Adding more of your projects to your Directory Profile builds a more complete pi
102102

103103
1. Make sure `stackmuncher` executable is placed in a folder included in `PATH` environment variable or add its folder to `PATH`.
104104
2. Check if you have Git hooks already configured: `git config --get-all init.templatedir`
105-
* _the query returned a value_ - edit your post-commit templates manually
106-
* _the query returned nothing_ - add a [post-commit Git hook](https://git-scm.com/docs/githooks#_post_commit):
105+
* _if the query returned a value_ - edit your post-commit templates manually
106+
* _if the query returned nothing_ - add a [post-commit Git hook](https://git-scm.com/docs/githooks#_post_commit):
107+
108+
#### Shell
107109
```bash
108110
git config --global --add init.templatedir '~/.git-templates'
109111
mkdir -p ~/.git-templates/hooks
110112
echo 'stackmuncher --log info 2>&1 >> ~/.stm.log' >> ~/.git-templates/hooks/post-commit
111113
chmod a+x ~/.git-templates/hooks/post-commit
112114
```
115+
#### PowerShell
116+
```bash
117+
git config --global --add init.templatedir '~/.git-templates'
118+
mkdir -p ~/.git-templates/hooks
119+
echo '#!/bin/sh' >> ~/.git-templates/hooks/post-commit
120+
echo 'stackmuncher --log info 2>&1 >> ~/.stm.log' >> ~/.git-templates/hooks/post-commit
121+
```
122+
113123
3. Run `git init` on your existing repos to add the hook from the template.
114124
* Any new repos or clones will get the hook added by default.
115125
* Repos with an existing `hooks/post-commit` file can have the hook added with `echo 'stackmuncher --log info 2>&1 >> ~/.stm.log' >> .git/hooks/post-commit`. Run it from the root of the project folder.

stackmuncher/src/config.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,12 @@ pub(crate) async fn new_lib_config_with_defaults(current_dir: PathBuf) -> (LibCo
347347
)
348348
} else if cfg!(target_os = "windows") {
349349
// apps should store their data in the user profile and the exact location is obtained via an env var
350-
let local_appdata_dir = std::env::var("HOMEPATH").expect("%HOMEPATH% env variable not found");
351-
let local_appdata_dir = Path::new(&local_appdata_dir);
350+
// homedrive would be something like c: and homedir would be `\Users\admin`
351+
// if homedrive is not used the current active drive is used
352+
let home_drive = std::env::var("HOMEDRIVE").expect("%HOMEDRIVE% env variable not found");
353+
let home_dir = std::env::var("HOMEPATH").expect("%HOMEPATH% env variable not found");
354+
let home_dir = [home_drive, home_dir].concat();
355+
let local_appdata_dir = Path::new(&home_dir);
352356
(
353357
local_appdata_dir.join(REPORT_FOLDER_NAME_WIN),
354358
local_appdata_dir.join(CONFIG_FOLDER_NAME_WIN),

0 commit comments

Comments
 (0)