Skip to content
New issue

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

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

Already on GitHub? # to your account

submodules break release-opinion #60

Closed
paleozogt opened this issue May 14, 2015 · 12 comments
Closed

submodules break release-opinion #60

paleozogt opened this issue May 14, 2015 · 12 comments

Comments

@paleozogt
Copy link

Using submodules breaks grgit's release-opinion. Even when run directly on a tag (e.g., '1.1.0') it will produce versions as if it had uncommitted changes (e.g., '1.1.1-dev.0.uncommitted+2db5eac').

I've written up a minimal project that reproduces this problem here.

If we checkout the project:

> git --version
git version 2.4.0
> 
> git clone git@github.com:paleozogt/paleozogt-sandbox.git
   ...snip...
> 
> cd paleozogt-sandbox 

and then checkout a tag that doesn't use a submodule, it works fine:

> git checkout 1.0.0
   ...snip...
> git describe
1.0.0
>
> ./gradlew tasks
project version 1.0.0
git describe 1.0.0
:tasks
   ...snip...

But if we then checkout a tag that does use a submodule, it produces 'dirty' version numbers (despite git describe being simple):

> git checkout 1.1.0
   ...snip...
>
> git submodule sync
> git submodule update --init
   ...snip...
>
> git describe
1.1.0
>
> ./gradlew tasks
Inferred project: paleozogt-sandbox, version: 1.1.1-dev.0.uncommitted+2db5eac
project version 1.1.1-dev.0.uncommitted+2db5eac
git describe 1.1.0
:tasks
   ...snip...

One other thing that popped out at me is that in the submodule-using tag, grgit outputs 'Inferred project ...', but it doesn't output this in the tag that doesn't use a submodule. This seems to imply that grgit is going down different code-paths for the two tags.

@paleozogt
Copy link
Author

fyi I also tried this using git 1.9.5 and got the same results.

@ajoberstar
Copy link
Owner

Adding println git.status() shows the following in your 1.1.0 tag.

org.ajoberstar.grgit.Status(staged:org.ajoberstar.grgit.Status$Changes(added:[], modified:[], removed:[]), unstaged:org.ajoberstar.grgit.Status$Changes(added:[], modified:[build.gradle], removed:[grgit]))

This is just showing that the root cause is that Grgit interprets the grgit entry as a "removed" but "unstaged" change. Looking at where this comes from, JGit is interpreting that submodule as a "missing" file.

Still digging to see why that's the case.

@ajoberstar
Copy link
Owner

OK, next I tried:

git submodule init
git submodule update

Now rerunning gradlew tasks shows:

project version: 1.1.0
git describe: 1.1.0

So as long as the submodules are fully checked out, it looks like it works just fine. Let me know if that also resolves it for you.

@ajoberstar
Copy link
Owner

Feel free to reopen if that didn't resolve the issue for you.

@paleozogt
Copy link
Author

Sorry I wasn't able to get back to you promptly. I'm not getting the behavior you're describing-- the git submodule init/update doesn't change how grgit/jgit sees the submodule:

> git --version
git version 2.4.0
>
> git clone git@github.com:paleozogt/paleozogt-sandbox.git
Cloning into 'paleozogt-sandbox'...
remote: Counting objects: 411, done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 411 (delta 4), reused 0 (delta 0), pack-reused 399
Receiving objects: 100% (411/411), 1.32 MiB | 1.42 MiB/s, done.
Resolving deltas: 100% (76/76), done.
Checking connectivity... done.
>
> cd paleozogt-sandbox 
>
> git describe
1.2.0
>
> git submodule init
Submodule 'grgit' (git@github.com:ajoberstar/grgit.git) registered for path 'grgit'
>
> git submodule update
Cloning into 'grgit'...
remote: Counting objects: 4727, done.
remote: Compressing objects: 100% (238/238), done.
remote: Total 4727 (delta 171), reused 0 (delta 0), pack-reused 4452
Receiving objects: 100% (4727/4727), 1.72 MiB | 1.24 MiB/s, done.
Resolving deltas: 100% (2989/2989), done.
Checking connectivity... done.
Submodule path 'grgit': checked out '0da1151ce5ad67ab251ea5cd080f3531e8cad3c0'
>
> git status
On branch grgit_tests
Your branch is up-to-date with 'origin/grgit_tests'.
nothing to commit, working directory clean
>
> ./gradlew tasks
Inferred project: paleozogt-sandbox, version: 1.2.1-dev.0.uncommitted+1f285fc
project version 1.2.1-dev.0.uncommitted+1f285fc
git describe 1.2.0
git status org.ajoberstar.grgit.Status(staged:org.ajoberstar.grgit.Status$Changes(added:[], modified:[], removed:[]), unstaged:org.ajoberstar.grgit.Status$Changes(added:[], modified:[grgit], removed:[]))
   ...snip...
> 

I added the print of git.status()-- like you said, it looks like JGit thinks the grgit submodule isn't there. What's weird is that this doesn't match up with git status. I'm not sure how to use the command-line git to see what JGit is seeing.

@paleozogt
Copy link
Author

I downloaded jgit.sh and tried it on my repo. And it's also reporting that the submodule is modified:

> git status
On branch grgit_tests
Your branch is up-to-date with 'origin/grgit_tests'.
nothing to commit, working directory clean
>
> ~/Downloads/org.eclipse.jgit.pgm-3.7.1.201504261725-r.sh status
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
On branch grgit_tests
Changes not staged for commit:

    modified:   grgit

So this appears to be a JGit bug. :(

@paleozogt
Copy link
Author

After some more testing, I've realized this problem only happens on Mac OS X. (I'm on 10.9.5.)

@paleozogt
Copy link
Author

fyi, I've filed JGit 467631

@ajoberstar
Copy link
Owner

Thanks. If/when it gets fixed, I can bump the JGit version.

@ajoberstar
Copy link
Owner

Confirming that the JGit bug is still open as of 10/22/2017.

@vivin
Copy link

vivin commented Jul 28, 2018

I've committed a fix for this on JGit here.

@ajoberstar
Copy link
Owner

Just doing some cleanup. In theory, this should work now since the issue says it was fixed in 5.2 and grgit's on 5.9. Thanks @vivin for fixing. And feel free, anyone, to reopen if this is still occuring.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants