ajoberstar / gradle-git

Git plugin for Gradle
Apache License 2.0
561 stars 89 forks source link

Intellij Reporting `open` method is #240

Closed pluttrell closed 7 years ago

pluttrell commented 7 years ago

Intellij (2017.1 EAP) is reporting that the Grgit.open() method is deprecated. What should we use instead?

screen shot 2017-03-06 at 11 28 29 am

I'm using id "org.ajoberstar.grgit" version "1.6.0", which I understand to be the latest version.

For reference, I chose this open method based on this wiki article.

In case it matters, my use case is just to determine if my repo is clean/dirty, and I'm using repo.status().clean to determine such.

ajoberstar commented 7 years ago

The deprecated version of open is the one taking a single un-named argument. The documentation of OpenOp shows the new methods, which take named arguments depending on how exactly you want to search for the git directory.

I've also updated that wiki page to use a non-deprecated call.

pluttrell commented 7 years ago

@ajoberstar Thanks for getting back to me. I tried the named versions with the latest version (1.7.2) of the plugin and the latest version of Intellij (2017.2) and still have the same problem.

screen shot 2017-07-19 at 5 03 22 pm

In addition to dir:, I've tried currentDir: and see the same thing.

For reference here's the full build.gradle that demonstrates what I'm seeing:

buildscript {
    repositories {
        jcenter()
    }
}

plugins {
    id "org.ajoberstar.grgit" version "1.7.2"
}

apply plugin: 'java'

repositories {
    jcenter()
}

def repo = org.ajoberstar.grgit.Grgit.open(dir: '.')

task validateGitRepoClean {
    doFirst {
        assert repo.status().clean : 'Git repo found to contain uncommitted changes. A clean repo is required for this task'
    }
}
ajoberstar commented 7 years ago

This is an artifact of the way Grgit uses the Groovy MOP. The only concrete methods are the deprecated ones, so Intellij reports them that way.

This will be fixed in 2.0, but your usage is correct.