Coder Social home page Coder Social logo

Doesn't work on submodules. about gr HOT 7 CLOSED

spacemoose avatar spacemoose commented on September 17, 2024
Doesn't work on submodules.

from gr.

Comments (7)

mixu avatar mixu commented on September 17, 2024 2

merged & published

from gr.

balos1 avatar balos1 commented on September 17, 2024

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;
  },

from gr.

spacemoose avatar spacemoose commented on September 17, 2024

Hey, super. Thanks very much for that.

from gr.

bimlas avatar bimlas commented on September 17, 2024

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;

from gr.

bimlas avatar bimlas commented on September 17, 2024

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.

from gr.

bimlas avatar bimlas commented on September 17, 2024

Please help me in #65

from gr.

bimlas avatar bimlas commented on September 17, 2024

Just finished #65, please test it.

from gr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.