ajoberstar / grgit Goto Github PK
View Code? Open in Web Editor NEWThe Groovy way to use Git.
Home Page: https://ajoberstar.org/grgit/main/index.html
License: Apache License 2.0
The Groovy way to use Git.
Home Page: https://ajoberstar.org/grgit/main/index.html
License: Apache License 2.0
Support rebase similarly to merge, such that any merge conflicts result in an execution failure.
Hi, sorry I contact you like this, I couldn't find a better way. I can do this:
def repo = Grgit.open(project.baseDir)
def tags = repo.tag.list()
println tags
but I would need to get the tag on HEAD, just like git tag --points-at HEAD
. Is that possible?
For features that grgit doesn't have, it might be useful to be able to access the underlying JGit implementation. Something like Grgit.open('path/to/my/repo').getJGit()
I am still much confused by the authentication. I want to push to a remote, and I have the username and password contained in the remote URL, like https://<username>:<password>@github.com/xxx/xxx.git
, but it only works on my console. Every time I run the groovy script repo.push()
, there's a window asking about username and password. So is there a way to make it use the password in the URL? Thanks!
A common practice with Android projects is to derive the version code from the rev-list, e.g.
git rev-list HEAD --first-parent --count
grgit should have some way to access the rev-list, or as least a convenience method that gets the count.
error 05-May-2015 15:23:28 Caused by: groovy.lang.MissingMethodException: No signature of method: static org.ajoberstar.grgit.util.JGitUtil.convertCommit() is applicable for argument types: (org.eclipse.jgit.revwalk.RevTag) values: [tag 1eca2359f0969e94e04c281666590400aa315508 -----p]
error 05-May-2015 15:23:28 Possible solutions: convertCommit(org.eclipse.jgit.revwalk.RevCommit)
error 05-May-2015 15:23:28 at org.ajoberstar.grgit.util.JGitUtil$convertCommit$0.callStatic(Unknown Source)
error 05-May-2015 15:23:28 at org.ajoberstar.grgit.util.JGitUtil.resolveTag(JGitUtil.groovy:163)
error 05-May-2015 15:23:28 at org.ajoberstar.grgit.util.JGitUtil$resolveTag.call(Unknown Source)
error 05-May-2015 15:23:28 at org.ajoberstar.grgit.operation.TagListOp$_call_closure1.doCall(TagListOp.groovy:54)
error 05-May-2015 15:23:28 at org.ajoberstar.grgit.operation.TagListOp.call(TagListOp.groovy:53)
error 05-May-2015 15:23:28 at org.ajoberstar.grgit.operation.TagListOp.call(TagListOp.groovy)
error 05-May-2015 15:23:28 at java_util_concurrent_Callable$call$0.call(Unknown Source)
error 05-May-2015 15:23:28 at org.ajoberstar.grgit.util.OpSyntaxUtil.tryOp(OpSyntaxUtil.groovy:45)
error 05-May-2015 15:23:28 at org.ajoberstar.grgit.service.TagService.methodMissing(TagService.groovy:52)
error 05-May-2015 15:23:28 at pl.allegro.tech.build.axion.release.infrastructure.git.GitRepository.currentPosition(GitRepository.groovy:144)
error 05-May-2015 15:23:28 at pl.allegro.tech.build.axion.release.domain.scm.ScmRepository$currentPosition$0.call(Unknown Source)
error 05-May-2015 15:23:28 at pl.allegro.tech.build.axion.release.domain.VersionResolver.resolveVersion(VersionResolver.groovy:19)
error 05-May-2015 15:23:28 at pl.allegro.tech.build.axion.release.domain.VersionResolver$resolveVersion.call(Unknown Source)
error 05-May-2015 15:23:28 at pl.allegro.tech.build.axion.release.domain.VersionService.currentDecoratedVersion(VersionService.groovy:34)
error 05-May-2015 15:23:28 at pl.allegro.tech.build.axion.release.domain.VersionService$currentDecoratedVersion.call(Unknown Source)
error 05-May-2015 15:23:28 at pl.allegro.tech.build.axion.release.domain.VersionConfig.getVersion(VersionConfig.groovy:82)
error 05-May-2015 15:23:28 at pl.allegro.tech.build.axion.release.domain.VersionConfig_Decorated.getVersion(Unknown Source)
error 05-May-2015 15:23:28 at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.getProperty(BeanDynamicObject.java:153)
error 05-May-2015 15:23:28 at org.gradle.api.internal.BeanDynamicObject.getProperty(BeanDynamicObject.java:107)
error 05-May-2015 15:23:28 at org.gradle.api.internal.CompositeDynamicObject.getProperty(CompositeDynamicObject.java:78)
error 05-May-2015 15:23:28 at pl.allegro.tech.build.axion.release.domain.VersionConfig_Decorated.getProperty(Unknown Source)
Git supports pulling from a non-origin remote with pull and a different branch, can this be added?
Example of git command: git pull upstream feature/not-master
Some operations (like push) generate feedback which in some cases could useful to get know (here that remote branch was updated and a few (and which) tags were pushed on --follow-tags
). That could be especially helpful when tracking down problems with Git operations running on CI server in the Continuous Delivery process.
jgit returns those structures (like PushResult
), but it would be probably time consuming to map it into some GrGit structures, so maybe there could be added verbose
or verboseResults
switch to display on a console toString from that results (in case of push Collection<RemoteRefUpdate>
). WDYT?
Allowing to create archives from named trees using grgit would be great feature to have.
I'm trying to just open the repo and I get the error. Are there certain requirements on the repo? Here is the code in build.gradle.
import org.ajoberstar.grgit.*
ext.repo = Grgit.open(project.file('.'))
Error:Cause: org/ajoberstar/grgit/Grgit : Unsupported major.minor version 51.0
There doesn't seem to be a way to access git describe, e.g.:
git describe --tags --always --abbrev=7
This is super-useful for projects that use git tags for their versioning.
If you clone a local repository via Grgit.clone() and try to delete the repository folder after closing Grgit, the folder isn't deleted as .git/objects/pack/* files still seem to be locked (only on Windows of course).
Here is a small snippet to reproduce the problem:
package org.ajoberstar.grgit
import java.nio.file.Files
import java.nio.file.Path
def Path tempDir = Files.createTempDirectory 'tempfiles'
def File remoteRepo = Files.createTempDirectory(tempDir, 'remoteRepo').toFile()
def File localRepo = Files.createTempDirectory(tempDir, 'localRepo').toFile()
// Create the remote repository
def Grgit grgitRemote = Grgit.init(dir: remoteRepo)
new File(remoteRepo, 'test.txt') << UUID.randomUUID().toString() + File.separator
grgitRemote.add(patterns: ['test.txt'])
grgitRemote.commit(message: 'Initial commit')
// Create local repository by cloning the 'remote' repository
def Grgit grgitLocal = Grgit.clone(dir: localRepo, uri: remoteRepo)
// Close local repo
grgitLocal.close()
// Close remote repo
grgitRemote.close()
assert(remoteRepo.deleteDir() && !remoteRepo.isDirectory())
assert(localRepo.deleteDir() && !localRepo.isDirectory())
Git itself supports passing username or/and password in HTTPS connection URL, e.g.
That mechanism is used for example when pushing to GitHub from CI server with security tokens.
There is a simple workaround - passing username/password in Credential object, but it could be hard to apply/not supported when GrGit is used through the 3rd tools. Therefore it would be good to support also credentials encoded in the URL.
https://github.com/blog/1938-git-client-vulnerability-announced
Version 3.5.3.201412180710-r should be not affected.
Since Git does auto expansion on abbreviated Ids, I expected this method to do the same... that is, I expect it to call git to get the abbreviated id so that the id returned is the same as on the command line using the command git log --abbrev-commit --pretty=oneline
.
See git documentations at http://git-scm.com/book/en/Git-Tools-Revision-Selection
Hi,
I'm encountering this error:
* What went wrong:
Execution failed for task ':onlyFFmerge'.
> Could not find property 'MergeOp' on task ':onlyFFmerge'.
This is my script:
buildscript {
repositories { mavenCentral() }
dependencies { classpath "org.ajoberstar:grgit:0.2.2" }
}
import org.ajoberstar.grgit.*
task onlyFFmerge(){
doLast{
def repo = Grgit.open(".")
repo.merge(mode: MergeOp.Mode.ONLY_FF)
// This works fine:
// repo.merge(head: "myBranch")
}
}
Is this a bug or am I missing something?
Thanks.
Recursive deletion is important to mimic add --all
as specified in #53, however it is also useful for re-applying a .gitignore
file.
I would like to perform a git checkout --orphan <new_branch>
from a Gradle build script. Would this be feasible to implement?
Thanks for grgit!
One of the most important features I use in git is add --all
, which removes files that have been deleted from the index. This can technically be simulated with remove --cached -r .
followed by add
, but running one operation is better than two.
We would need to get the info about the tree in git since we use gerrit/zuul which merges and the tree is the only unique identifier.
git cat-file -p HEAD
shows the tree info among other information.
My usecase is:
grgit.head().tree
When I run status().isClean() on my repository, it always returns false because I have a symlink in it.
billmag:~/code/github/android-sdk$ git status
On branch feature/release-script
nothing to commit, working directory clean'
The value of Grgit.open('.').status() is:
org.ajoberstar.grgit.Status(staged:org.ajoberstar.grgit.Status$Changes(added:[], modified:[], removed:[]), unstaged:org.ajoberstar.grgit.Status$Changes(added:[], modified:[android-sdk-base/src], removed:[]))
It is a symlink, to elsewhere in the repository, but it's certainly unchanged and I can confirm it works in a fresh checkout:
billmag:~/code/github/android-sdk$ ls -la android-sdk-base/src
lrwxr-xr-x 1 billmag staff 28 May 19 19:32 android-sdk-base/src -> android-sdk-base-private/src
There doesn't seem to be a way to access the current branch name, e.g.:
git rev-parse --abbrev-ref HEAD
This is super-useful for projects that include the branch-name in their versioning.
Without setting this, using closure syntax in a Gradle task declaration sets all properties as dynamic properties on the task instead of setting them on the GitOp.
I've got a question about the ranges in grgit.log.
I know that I can use the command-line git to do something like
git log v0.0.1 --oneline
to get all the commits from the very beginning to the tag "v0.0.1"
I tried to get the same working with grgit, but I can't figure out how!
Can one of the ranges of grgit.log be skipped (if so, how)?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.