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

GitAdapter constructor fails when trying to find current branch #286

Open
carlosmagan opened this issue Feb 6, 2019 · 2 comments
Open
Labels

Comments

@carlosmagan
Copy link

Affected version: 2.8.0
Last unaffected version: 2.7.0

Behavior:
When creating BaseScmAdapter for each type it should find the right type depending on the repo type being used (Git, Svn, Mercurial...).

GitAdapter constructor not only instantiates the adapter but tries to find the current branch which provokes an exception when the repo type is not git and release fails.

2.8.0

GitAdapter(Project project, Map<String, Object> attributes) {
        super(project, attributes)

        workingBranch = gitCurrentBranch() //this is the line raising the exception
        releaseBranch = extension.pushReleaseVersionBranch ? extension.pushReleaseVersionBranch : workingBranch
    }

2.7.0

GitAdapter(Project project, Map<String, Object> attributes) {
        super(project, attributes)
    }

Expected behaviour:
In prior versions the adapter was instantiated and validated before trying to make any repo operations.

Steps to reproduce:
Try to release a Mercurial repo with gradle-release version 2.8.0

@carlosmagan carlosmagan changed the title Git Adapter constructor fails when trying to find current branch GitAdapter constructor fails when trying to find current branch Feb 6, 2019
@carlosmagan
Copy link
Author

carlosmagan commented Feb 6, 2019

Gradle version is 5.1.1

The command I'm running is:
gradlew release
The error obtained is:

Task :xxxxx-gradle:createScmAdapter FAILED
Running [git, branch, --no-color] produced an error: [fatal: not a git repository (or any of the parent directories): .git]

Task :release FAILED
Running [git, branch, --no-color] produced an error: [fatal: not a git repository (or any of the parent directories): .git]
Release process failed, please remember to revert any uncommitted changes made by the Release Plugin.

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':xxxxx-gradle:createScmAdapter'.

java.lang.reflect.InvocationTargetException

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 3s
1 actionable task: 1 executed

@swpalmer
Copy link

This should be fixed as the search for .git, .hg, .svn, etc. should happen first to pick the correct SCM adapter. However there is a workaround if you know you are using a superior SCM system like Mercurial ;-) - specify the SCM adapter to use:

release {
    scmAdapters = [
        net.researchgate.release.HgAdapter
    ]
}

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

No branches or pull requests

3 participants