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

Improve gitdir handling with submodules #135

Merged
merged 2 commits into from
Nov 9, 2014
Merged

Improve gitdir handling with submodules #135

merged 2 commits into from
Nov 9, 2014

Conversation

maiergre
Copy link
Contributor

Thanks for the plugin!

This pull req fixes two issues I encountered:

  • When using git submodules some older git version (e.g., 1.7.9, used by Ubuntu 12.04 LTS) use absolute path in the .git gitdir reference. I've added support for absolute path.
  • When searching for the gitdir the plugin should search the parent directory not the parent project. Esp. with submodules searching the parent project is not correct since the parent might be in a different git repo.

When using git submodules, some versions of git (e.g., 1.7.9) use
abosulate path in the gitdir reference of the submodules. This patch
adds support to handle absoluate path correctly.
When searching for the git directory of a project the search follows
the project's basedir parent directory rather than following the
project hierarchy (which is not correct)
@maiergre
Copy link
Contributor Author

FYI, the second point is similar to #128 however #128 doesn't work for submodules

@maiergre
Copy link
Contributor Author

maiergre commented Nov 7, 2014

@ktoso I was wondering whether you had a chance to look at this pull request

@ktoso
Copy link
Collaborator

ktoso commented Nov 7, 2014

Sorry, not yet, was very busy with Akka this week. But should be able to
look tomorrow :-)

Thanks for your patience!

Konrad
(sent from mobile)
On 7 Nov 2014 19:20, "Gregor Maier" notifications@github.com wrote:

@ktoso https://github.com/ktoso I was wondering whether you had a
chance to look at this pull request


Reply to this email directly or view it on GitHub
#135 (comment)
.

File basedir = mavenProject.getBasedir();
while (basedir != null) {
File gitdir = new File(basedir, Constants.DOT_GIT);
if (gitdir != null && gitdir.exists()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gitdir is always != null here

@ktoso
Copy link
Collaborator

ktoso commented Nov 9, 2014

Seems good to me, and tests pass. Unless I missed some edge case this should be fine - thanks for the contribution!

ktoso added a commit that referenced this pull request Nov 9, 2014
Improve gitdir handling with submodules
@ktoso ktoso merged commit 77679ab into git-commit-id:master Nov 9, 2014
@ktoso ktoso added this to the 2.1.12 milestone Dec 8, 2014
@klion26
Copy link

klion26 commented Aug 31, 2024

Hi thanks for the great project, so that we can track the commit message in the distribute env easily.

I have a question about searching for .git in the parent directory: do we need to add an option to not search the parent directory when finding the .git dir? I am not sure if this is a normal case or not, I encountered this in some testing processes. thanks.

Now we will search all parent directories from the current directory to find the .git directory, but when I configure failOnNoGitDirectory to true and there is a .git directory in a parent directory, the compilation will not report an error and fail, but the .git directory founded in the parent directory will be used as the information of the project.

The background of this case is that I am contributing to an open-source project. this project wants to report an error without .git under the usual process, but the project also provides a zip package download method to compile without .git. When I tested it, I moved the .git directory to the parent directory of the project and found it passed the compilation and did not report any error.

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.

None yet

3 participants