git-cmd's People
git-cmd's Issues
jgit checkoutSubmodule() broken
checkoutSubmodule() raises an exception for https git repos that have submodules when using the gocd-build-github-pull-requests plugin:
2015-05-17 15:09:48,725 WARN [89@MessageListener for MaterialUpdateListener] GitHubPRBuildPlugin:67 - get latest revision:
java.lang.RuntimeException: checkout all sub-modules failed
at com.tw.go.plugin.jgit.JGitHelper.checkoutAllModifiedFilesInSubmodules(JGitHelper.java:412)
at com.tw.go.plugin.GitHelper.fetchAndReset(GitHelper.java:108)
at com.tw.go.plugin.GitHelper.fetchAndResetToHead(GitHelper.java:95)
at com.tw.go.plugin.GitHelper.cloneOrFetch(GitHelper.java:41)
at in.ashwanthkumar.gocd.github.GitHubPRBuildPlugin.handleGetLatestRevision(GitHubPRBuildPlugin.java:156)
at in.ashwanthkumar.gocd.github.GitHubPRBuildPlugin.handle(GitHubPRBuildPlugin.java:81)
at com.thoughtworks.go.plugin.infra.DefaultPluginManager$1.execute(DefaultPluginManager.java:172)
at com.thoughtworks.go.plugin.infra.DefaultPluginManager$1.execute(DefaultPluginManager.java:167)
at com.thoughtworks.go.plugin.infra.FelixGoPluginOSGiFramework.executeActionOnTheService(FelixGoPluginOSGiFramework.java:315)
at com.thoughtworks.go.plugin.infra.FelixGoPluginOSGiFramework.doOn(FelixGoPluginOSGiFramework.java:245)
at com.thoughtworks.go.plugin.infra.DefaultPluginManager.submitTo(DefaultPluginManager.java:167)
at com.thoughtworks.go.plugin.access.PluginRequestHelper.submitRequest(PluginRequestHelper.java:33)
at com.thoughtworks.go.plugin.access.scm.SCMExtension.getLatestRevision(SCMExtension.java:135)
at com.thoughtworks.go.server.service.materials.PluggableSCMMaterialPoller.latestModification(PluggableSCMMaterialPoller.java:61)
at com.thoughtworks.go.server.service.materials.PluggableSCMMaterialPoller.latestModification(PluggableSCMMaterialPoller.java:46)
at com.thoughtworks.go.server.service.MaterialService.latestModification(MaterialService.java:106)
at com.thoughtworks.go.server.materials.LegacyMaterialChecker.findLatestModification(LegacyMaterialChecker.java:49)
at com.thoughtworks.go.server.materials.ScmMaterialUpdater.insertLatestOrNewModifications(ScmMaterialUpdater.java:52)
at com.thoughtworks.go.server.materials.ScmMaterialUpdater.addNewMaterialWithModifications(ScmMaterialUpdater.java:72)
at com.thoughtworks.go.server.materials.PluggableSCMMaterialUpdater.addNewMaterialWithModifications(PluggableSCMMaterialUpdater.java:66)
at com.thoughtworks.go.server.materials.MaterialDatabaseUpdater.addNewMaterialWithModifications(MaterialDatabaseUpdater.java:178)
at com.thoughtworks.go.server.materials.MaterialDatabaseUpdater.initializeMaterialWithLatestRevision(MaterialDatabaseUpdater.java:134)
at com.thoughtworks.go.server.materials.MaterialDatabaseUpdater.access$000(MaterialDatabaseUpdater.java:47)
at com.thoughtworks.go.server.materials.MaterialDatabaseUpdater$1.doInTransaction(MaterialDatabaseUpdater.java:95)
at com.thoughtworks.go.server.transaction.TransactionCallback.doWithExceptionHandling(TransactionCallback.java:24)
at com.thoughtworks.go.server.transaction.TransactionTemplate$3.doInTransaction(TransactionTemplate.java:53)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
at com.thoughtworks.go.server.transaction.TransactionTemplate.executeWithExceptionHandling(TransactionTemplate.java:49)
at com.thoughtworks.go.server.materials.MaterialDatabaseUpdater.updateMaterial(MaterialDatabaseUpdater.java:92)
at com.thoughtworks.go.server.materials.MaterialUpdateListener.onMessage(MaterialUpdateListener.java:48)
at com.thoughtworks.go.server.materials.MaterialUpdateListener.onMessage(MaterialUpdateListener.java:29)
at com.thoughtworks.go.server.messaging.activemq.JMSMessageListenerAdapter.runImpl(JMSMessageListenerAdapter.java:65)
at com.thoughtworks.go.server.messaging.activemq.JMSMessageListenerAdapter.run(JMSMessageListenerAdapter.java:50)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: sub-module checkout failed
at com.tw.go.plugin.jgit.JGitHelper.checkoutSubmodule(JGitHelper.java:427)
at com.tw.go.plugin.jgit.JGitHelper.checkoutAllModifiedFilesInSubmodules(JGitHelper.java:409)
... 33 more
Caused by: org.eclipse.jgit.api.errors.InvalidRefNameException: Branch name <null> is not allowed
at org.eclipse.jgit.api.CheckoutCommand.processOptions(CheckoutCommand.java:493)
at org.eclipse.jgit.api.CheckoutCommand.call(CheckoutCommand.java:202)
at com.tw.go.plugin.jgit.JGitHelper.checkoutSubmodule(JGitHelper.java:425)
... 34 more
Publish to Maven Central
@srinivasupadhya Can we publish the git-cmd
module to Maven Central? Let me know if you need some help on that.
Ability to fetch up to a certain depth, or/and up to a certain revision
Hey,
It would be great to be able to fetch up until a given revision, something like: fetchUpToAtLeastRevision(String revision)
or fetch(Integer depth)
. This would enable shallow clones on ashwanthkumar/gocd-build-github-pull-requests#67 (comment)
fetchAndReset() broken with git submodules
When using gocd-build-github-pull-requests with a repo with git submodules and over SSH, the call to fetchAndReset()
raises exception as documented here: ashwanthkumar/gocd-build-github-pull-requests#31
2015-05-16 06:11:44,640 WARN [84@MessageListener for MaterialUpdateListener] GitHubPRBuildPlugin:67 - get latest revisions since:
java.lang.RuntimeException: Exception Occurred: [git, config, --get-regexp, ^submodule\..+\.url] - /var/lib/go-server/pipelines/flyweight/3d83eae3-92a0-4b48-83b5-8a72e7d44e8d
at com.tw.go.plugin.cmd.Console.runOrBomb(Console.java:33)
at com.tw.go.plugin.git.GitCmdHelper.runAndGetOutput(GitCmdHelper.java:386)
at com.tw.go.plugin.git.GitCmdHelper.submoduleUrls(GitCmdHelper.java:233)
at com.tw.go.plugin.git.GitCmdHelper.cleanAllUnversionedFiles(GitCmdHelper.java:211)
at com.tw.go.plugin.GitHelper.fetchAndReset(GitHelper.java:100)
at com.tw.go.plugin.GitHelper.fetchAndResetToHead(GitHelper.java:95)
at com.tw.go.plugin.GitHelper.cloneOrFetch(GitHelper.java:41)
at in.ashwanthkumar.gocd.github.GitHubPRBuildPlugin.handleLatestRevisionSince(GitHubPRBuildPlugin.java:185)
at in.ashwanthkumar.gocd.github.GitHubPRBuildPlugin.handle(GitHubPRBuildPlugin.java:83)
at com.thoughtworks.go.plugin.infra.DefaultPluginManager$1.execute(DefaultPluginManager.java:172)
at com.thoughtworks.go.plugin.infra.DefaultPluginManager$1.execute(DefaultPluginManager.java:167)
at com.thoughtworks.go.plugin.infra.FelixGoPluginOSGiFramework.executeActionOnTheService(FelixGoPluginOSGiFramework.java:315)
at com.thoughtworks.go.plugin.infra.FelixGoPluginOSGiFramework.doOn(FelixGoPluginOSGiFramework.java:245)
at com.thoughtworks.go.plugin.infra.DefaultPluginManager.submitTo(DefaultPluginManager.java:167)
at com.thoughtworks.go.plugin.access.PluginRequestHelper.submitRequest(PluginRequestHelper.java:33)
at com.thoughtworks.go.plugin.access.scm.SCMExtension.latestModificationSince(SCMExtension.java:154)
at com.thoughtworks.go.server.service.materials.PluggableSCMMaterialPoller.modificationsSince(PluggableSCMMaterialPoller.java:77)
at com.thoughtworks.go.server.service.materials.PluggableSCMMaterialPoller.modificationsSince(PluggableSCMMaterialPoller.java:46)
at com.thoughtworks.go.server.service.MaterialService.modificationsSince(MaterialService.java:110)
at com.thoughtworks.go.server.materials.ScmMaterialUpdater.insertLatestOrNewModifications(ScmMaterialUpdater.java:52)
at com.thoughtworks.go.server.materials.PluggableSCMMaterialUpdater.insertLatestOrNewModifications(PluggableSCMMaterialUpdater.java:61)
at com.thoughtworks.go.server.materials.MaterialDatabaseUpdater.insertLatestOrNewModifications(MaterialDatabaseUpdater.java:155)
at com.thoughtworks.go.server.materials.MaterialDatabaseUpdater.updateMaterialWithNewRevisions(MaterialDatabaseUpdater.java:147)
at com.thoughtworks.go.server.materials.MaterialDatabaseUpdater$2.doInTransaction(MaterialDatabaseUpdater.java:110)
at com.thoughtworks.go.server.transaction.TransactionCallback.doWithExceptionHandling(TransactionCallback.java:24)
at com.thoughtworks.go.server.transaction.TransactionTemplate$3.doInTransaction(TransactionTemplate.java:53)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
at com.thoughtworks.go.server.transaction.TransactionTemplate.executeWithExceptionHandling(TransactionTemplate.java:49)
at com.thoughtworks.go.server.materials.MaterialDatabaseUpdater.updateMaterial(MaterialDatabaseUpdater.java:107)
at com.thoughtworks.go.server.materials.MaterialUpdateListener.onMessage(MaterialUpdateListener.java:48)
at com.thoughtworks.go.server.materials.MaterialUpdateListener.onMessage(MaterialUpdateListener.java:29)
at com.thoughtworks.go.server.messaging.activemq.JMSMessageListenerAdapter.runImpl(JMSMessageListenerAdapter.java:65)
at com.thoughtworks.go.server.messaging.activemq.JMSMessageListenerAdapter.run(JMSMessageListenerAdapter.java:50)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:153)
at com.tw.go.plugin.cmd.Console.runOrBomb(Console.java:25)
fetchAndReset() immediately calls cleanAllUnversionedFiles()
cleanAllUnversionedFiles() make a call to submoduleUrls() which makes the call git config --get-regexp ^submodule\\..+\\.url
to return the urls for all submodules, which FAILS because submodules must be initialized for that call to work.
The issue is that cleanAllUnversionedFiles check for submodules simply by looking for the config, but does not check to see that they are inittialized before calling submoduleUrls()
Potential fix is to add a call to submoduleInit()
inside of fetchAndReset() before the first call to cleanAllUnversionedFiles():
public void fetchAndReset(String revision, String refSpec) {
stdOut.consumeLine(String.format("[GIT] Fetch and reset in working directory %s", workingDir));
submoduleInit();
cleanAllUnversionedFiles();
if (isSubmoduleEnabled()) {
removeSubmoduleSectionsFromGitConfig();
}
fetch(refSpec);
gc();
resetHard(revision);
if (isSubmoduleEnabled()) {
checkoutAllModifiedFilesInSubmodules();
updateSubmoduleWithInit();
}
cleanAllUnversionedFiles();
}
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.