passsy / gradle-GitVersioner

generates a project version for the given git project to distinguish between builds
Apache License 2.0
81 stars 22 forks source link

Error:can't generate a git version, this is not a git project #9

Open joxad opened 7 years ago

joxad commented 7 years ago

Hello,

I have this error but I don't understand because I am in a git project : If I use git status it's working correctly : image I guess this is a problem between git/gradle ?

joxad commented 7 years ago

my gradle


apply from: 'https://raw.githubusercontent.com/passsy/gradle-GitVersioner/master/git-versioner.gradle'

def version= "${major}.${minor}.${patch}"
def code = gitVersion.version

android {

    compileSdkVersion rootProject.ext.androidCompileSdkVersion
    buildToolsVersion rootProject.ext.androidBuildToolsVersion

    dataBinding {
        enabled = true
    }
    defaultConfig {
        applicationId "xxx"
        minSdkVersion rootProject.ext.androidMinSdkVersion
        targetSdkVersion rootProject.ext.androidTargetSdkVersion
        versionCode code
        versionName version
    }
}`
passsy commented 7 years ago

This can happen if there is no .git folder. check if you can run git status manually. If you are executing on macOS, make sure you have started Xcode after you installed the last update.

LeiWangAndroid commented 6 years ago

Hi,

I am also facing the same issue, with the error:

-> Not a git repository (or any of the parent directories): .git ERROR: can't generate a git version, this is not a git project

and the lines:

// check if git project
def status = 'git status'.execute([], rootDir)
status.waitFor()
def isGitProject = status.exitValue()

is always returning 128.

The thing is, this script was working perfectly before, but recently, it is starting not working, not sure what is wrong...

I am using macOS, and has Android Studio 3.0

Thanks.

passsy commented 6 years ago

If you recently upgraded macOS you have to start Xcode and install the required components. Do you have brew installed? What's the output of brew doctor? Brew would runs into the same problems.

Also consider upgrading to https://github.com/passsy/gradle-GitVersioner

LeiWangAndroid commented 6 years ago

Thanks, @passsy , It works now :)

I think somehow the git on my mac is not linked with Brew, I tried it now, and it is working perfectly.