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

Doesn't work on submodules. #54

Closed
spacemoose opened this issue Sep 30, 2016 · 7 comments
Closed

Doesn't work on submodules. #54

spacemoose opened this issue Sep 30, 2016 · 7 comments

Comments

@spacemoose
Copy link

If foo/ is a git repo containing a submodule bar/, and I try to execute 'status' on bar, I get: "Missing .git directory". Any chance this can generalized to work for submodules?

@balos1
Copy link
Contributor

balos1 commented Oct 10, 2016

I too have found myself wishing this would work with submodules. I believe it can be made to work pretty easily. All that seemingly needs to change is this function. Just need to check if the parent directory has a .gitmodules file, and a .git directory. I will try and submit a PR with these changes.

  git: function(req) {
    var stat;
    try {
      stat = fs.statSync(req.path + '/.git/');
      if (stat.isDirectory()) {
        return true;
      }
    } catch (e) { }
    if (req.format === 'human') {
      console.log('Skipped ' + req.path + ' as it does not have a .git subdirectory.');
    }
    return false;
  },

mixu added a commit that referenced this issue Oct 16, 2016
Add support for git submodules. Addresses issue #54.
@mixu
Copy link
Owner

mixu commented Oct 16, 2016

merged & published

@mixu mixu closed this as completed Oct 16, 2016
@spacemoose
Copy link
Author

Hey, super. Thanks very much for that.

@bimlas
Copy link
Contributor

bimlas commented Mar 14, 2017

It works if the submodule is the first child of the root directory but not works if the submodule is in foo/more/than/one/level/bar. I don't speak Java, but I know that some kind of globbing should do the trick here, or a loop like:

      while !empty(req.path) {
        var parentPath = path.dirname(req.path);
        try {
          stat = fs.statSync(parentPath + '/.gitmodules');
          if (!stat.isFile()) {
            var req.path = removeLastPart(req.path);
          }
        } catch (e) { }
      }
      return empty(req.path) ? false : true;

@bimlas
Copy link
Contributor

bimlas commented Mar 14, 2017

Another option: if .git is a file instead of a directory (so it's a submodule), then read the contents, for example:

gitdir: ../../../../.git/more/than/one/level/bar

If it contains gitdir: than it's a submodule.

bimlas added a commit to bimlas/gr that referenced this issue 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 mixu#54
bimlas added a commit to bimlas/gr that referenced this issue 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 mixu#54
bimlas added a commit to bimlas/gr that referenced this issue 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 mixu#54
@bimlas
Copy link
Contributor

bimlas commented Mar 18, 2017

Please help me in #65

bimlas added a commit to bimlas/gr that referenced this issue Mar 25, 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 mixu#54
bimlas added a commit to bimlas/gr that referenced this issue Apr 7, 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 mixu#54
@bimlas
Copy link
Contributor

bimlas commented Apr 7, 2017

Just finished #65, please test it.

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

No branches or pull requests

4 participants