Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use git rev-parse to check path correctness #65

Merged
merged 1 commit into from
Sep 28, 2017

Conversation

bimlas
Copy link
Contributor

@bimlas bimlas commented Mar 18, 2017

Instead of check the existness of .git directory, use git rev-parse
to check that req.path is in

  • a Git repository
  • a Git submodule
  • the root of the repo/submodule

The old method didn't worked with submodules more than one level deep in
the repo. Besides this if the $GIT_DIR differs from .git (cannot find
a real life example), then the old method fails to work.

Related to #54

It's using git rev-parse --show-prefix which drops error if executed outside of Git repository; prints the prefix ("the current directory relative to Git root") if executed from a subdirectory. The behaviour if equal for Git repo and submodule too.

Curently it's not working because I can't return true/false from exec, so I need help in making it usable.

Please be patient, it's my very first Node.js code and I'm beginner in Javascript too.

Instead of check the existness of `.git` directory, use `git rev-parse`
to check that `req.path` is in

* a Git repository
* a Git submodule
* the root of the repo/submodule

The old method didn't worked with submodules more than one level deep in
the repo. Besides this if the $GIT_DIR differs from `.git` (cannot find
a real life example), then the old method fails to work.

Related to mixu#54
@bimlas bimlas force-pushed the submodule-in-subdirectory branch from b2163ba to ebbacfb Compare April 7, 2017 21:49
@bimlas
Copy link
Contributor Author

bimlas commented Apr 7, 2017

Finally, it works as expected.

An example output (reformatted to be more readable):

$ gr git status --short --branch

Skipped ~/not-a-git-repo as it is not a Git repository.

in ~/git-repo
## master...origin/master

in ~/git-repo/submodule
## master...origin/master

Skipped ~/git-repo/more/than as it is not the root of Git repository or submodule.

in ~/git-repo/more/than/one/level/submodule
## master...origin/master

@bimlas
Copy link
Contributor Author

bimlas commented Apr 28, 2017

@mixu, please review and merge if you agree.

@mixu mixu merged commit 2159729 into mixu:master Sep 28, 2017
@mixu
Copy link
Owner

mixu commented Sep 28, 2017

thanks! sorry for the long delay in merging!

@mixu
Copy link
Owner

mixu commented Sep 28, 2017

published on npm as v0.5.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants