grgit.add()不向登台

时间:2017-09-15 17:21:16

标签: git gradle grgit

我试图在我的一个项目中第一次设置这个,我很好奇为什么有些项目在我做grgit.add()之后仍然被认为是不上演的

我的build.gradle

task gitCommit {
    group = "Custom"
    description = "Commits the version build number changes to Git"

    doLast{
        VersionTracker.setPropertiesFile(versionPropertiesFilePath)
        def appBuildVersion = VersionTracker.getBuild()
        def commitMessage= "Incremented build number; " + appBuildVersion
        try
        {
            logger.lifecycle("Commiting to Git")
            logger.lifecycle("Before add:\n${grgit.status()}\n")

            // Adds all tracked files to staging for commit
            grgit.add(patterns: ["AndroidManifest.xml", "assets/version.properties"], update: true)
            logger.lifecycle("After add:\n${grgit.status()}\n")

            // Commits the tracked changes to the local repo
            grgit.commit(message: commitMessage)
            logger.lifecycle("After commit:\n${grgit.status()}")

            // Pushes the changes to the remote repo
            grgit.push()
        }
        catch (Exception e)
        {
            logger.error("Failed...", e)
        }
        finally
        {
            logger.lifecycle("Git connection closed")
            // grgit.close()
        }
    }
}

过程

在运行脚本之前,我运行以下命令:

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working tree clean

然后我运行一个gradle脚本来破坏版本,我得到了这个:

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   AndroidManifest.xml
    modified:   assets/version.properties

no changes added to commit (use "git add" and/or "git commit -a")

然后我运行gradle gitCommit来运行上面的脚本,输出以下内容:

Commiting to Git
Before add:
org.ajoberstar.grgit.Status(staged:org.ajoberstar.grgit.Status$Changes(added:[],modified:[], removed:[]), unstaged:org.ajoberstar.grgit.Status$Changes(added:[], modified: [Development/Android/AndroidManifest.xml, Development/Android/build.gradle, Development/Android/assets/version.properties, Development/Android/build.gradle, Development/Android/build.gradle], removed:[]), conflicts:[])

After add:
org.ajoberstar.grgit.Status(staged:org.ajoberstar.grgit.Status$Changes(added:[],modified:[], removed:[]), unstaged:org.ajoberstar.grgit.Status$Changes(added:[], modified: [Development/Android/AndroidManifest.xml, Development/Android/build.gradle, Development/Android/assets/version.properties, Development/Android/build.gradle, Development/Android/build.gradle], removed:[]), conflicts:[])

After commit:
org.ajoberstar.grgit.Status(staged:org.ajoberstar.grgit.Status$Changes(added:[],modified:[], removed:[]), unstaged:org.ajoberstar.grgit.Status$Changes(added:[], modified: [Development/Android/AndroidManifest.xml, Development/Android/build.gradle, Development/Android/assets/version.properties, Development/Android/build.gradle, Development/Android/build.gradle], removed:[]), conflicts:[])

BUILD SUCCESSFUL in 9s
1 actionable task: 1 executed

但是,我再次尝试git status并获得此信息:

$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   AndroidManifest.xml
    modified:   assets/version.properties

no changes added to commit (use "git add" and/or "git commit -a")

我看到我提前1次提交(在一些测试后是一个空提交),并且仍然没有为提交暂存的更改。任何想法如何解决这个问题并让grgit实际提交到repo,甚至添加更改以进行提交?

0 个答案:

没有答案