Skip to content

Commit

Permalink
Stop at .git folder
Browse files Browse the repository at this point in the history
Resolves #2
  • Loading branch information
korenmiklos committed Jul 31, 2020
1 parent ee78b51 commit 49fbf68
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
9 changes: 5 additions & 4 deletions here.ado
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
program define here, rclass
syntax [, nogit set]
* FIXME: implement .git

tempname here

Expand All @@ -15,7 +14,7 @@ program define here, rclass
local `current' = c(pwd)

* are we there yet?
are_we_there_yet
are_we_there_yet, `git'
while (_rc) {
* if at root folder without .here, stop with an error
if ("`c(pwd)'" == "") {
Expand All @@ -27,7 +26,7 @@ program define here, rclass
if (_rc) {
break_with_error, directory(``current'')
}
are_we_there_yet
are_we_there_yet, `git'
}

local `here' = c(pwd)
Expand All @@ -39,8 +38,10 @@ program define here, rclass
end

program define are_we_there_yet
syntax [, nogit]

capture confirm file ".here"
if (_rc != 0) {
if (_rc != 0) & ("`git'" != "nogit") {
capture confirm file ".git"
}
end
Expand Down
10 changes: 5 additions & 5 deletions here.hlp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ Type the command ^here^ anywhere inside a project folder and it will put the *ro
/Users/koren/projects/social-distancing/analysis/counterfactual

. here
/Users/koren/projects/social-distancing
/Users/koren/projects/social-distancing/

. display "${here}"
/Users/koren/projects/social-distancing
/Users/koren/projects/social-distancing/

. import delimited "${here}/data/raw/bls/employment.csv"

Expand All @@ -34,10 +34,10 @@ To fix the root folder, use ^here, set^.
/Users/koren/projects/social-distancing/analysis

. here, set
/Users/koren/projects/social-distancing/analysis
/Users/koren/projects/social-distancing/analysis/

. display ${here}
/Users/koren/projects/social-distancing/analysis
/Users/koren/projects/social-distancing/analysis/

Under the hood
--------------
Expand Down Expand Up @@ -69,4 +69,4 @@ Options

^set^ sets the root folder of the project.

^nogit^ ignores .git folders when finding the root folder. (Not implemented yet.)
^nogit^ ignores .git folders when finding the root folder.
2 changes: 1 addition & 1 deletion here.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ d 'here' roughly implements the behavior of the CRAN library with the same name.
d
d Author: Miklós Koren
d License: MIT
d Distribution-Date: 20200723
d Distribution-Date: 20200731
f here.ado
f here.hlp

0 comments on commit 49fbf68

Please sign in to comment.