/*
 * Copyright (C) 2018 Florian Dreier
 *
 * This file is part of MyTargets.
 *
 * MyTargets is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2
 * as published by the Free Software Foundation.
 *
 * MyTargets is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

import org.ajoberstar.grgit.Grgit

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'org.ajoberstar:grgit:2.1.0'
    }
}

ext {
    try {
        git = Grgit.open()
        gitVersionCode = git.tag.list().size()
        gitVersionName = git.describe()
                .replace("v", "")
                .replace("_b", "-Beta")
                .replace("_rc", "-RC")
        if(System.getenv('TRAVIS') == 'true') {
            gitBranchName = System.getenv('TRAVIS_BRANCH')
        } else {
            gitBranchName = git.branch.getCurrent().name
        }
    } catch(Exception e) {
        gitVersionCode = 1
        gitVersionName = "debug"
        gitBranchName = "debug"
    }
}
