jgit

Gerrit replicating to gitolite fails

人盡茶涼 提交于 2019-12-07 12:05:17
问题 I have configured the replication with following configurations $cat /var/gerrit/review_site/etc/replication.config [gerrit] autoReload=true [remote "bt-git"] projects = ^vt-(.*)$ push = refs/heads/*:refs/heads/* url = git@git.something.com:/${name}.git My ssh config file looks like this one, Host git HostName git.something.com User git IdentityFile /var/gerrit/.ssh/id_rsa StrictHostKeyChecking no UserKnownHostsFile /dev/null Although I have already added the right set of hostkeys in my ~/

Git fetch failing using jgit: Remote does not have <branchname> available for fetch

柔情痞子 提交于 2019-12-07 09:23:16
问题 I have a bare repo located at main.git and am trying to fetch a branch ( foo , let's say) in another repo, test , which has only just been git init 'd: fetchtest/ |- main.git/ |- test/ |- .git/ Using regular git commands, I can do a git fetch ../main.git foo:foo and this will make a new branch foo in test/ and fetch the objects required for the branch. I then want to do the same thing but programmatically using JGit, ie not using the git CLI but using only Java code. There is no way I can use

JGit : connect to distant repository

别说谁变了你拦得住时间么 提交于 2019-12-07 02:46:33
问题 I searched through Google, forums and JGit user guide but couldn't find how to connect to a distant repository with the API. Anyone has an example or just an idea on how to do that? Thanks for your help. 回答1: Currently, JGit 2.0.0-SNAPSHOT does only offer org.eclipse.jgit.storage.file.FileRepository org.eclipse.jgit.storage.dfs.InMemoryRepository concrete Repository classes, meaning that since org.eclipse.jgit.api.Git takes a Repository , it is not possible to work remotely. Since Git by

List branches of a git remote repo without cloning it

佐手、 提交于 2019-12-07 01:40:26
问题 I was wondering hows it would be possible to list all the branches of a remote Git repo with jgit but without cloning it. While going through the jgit's javadoc, I found the ListBranchCommand but that only seem to work with an already opened Repository object. But I was not able to find how to create a Repository object over HTTP without cloning it in local. Is it possible ? Thanks 回答1: There is the LsRemoteCommand to list the branches of a remote repository. To obtain the command, use either

what is the difference between getPeeledObjectId() and getObjectId() of Ref Object?

耗尽温柔 提交于 2019-12-06 15:49:17
I am using jgit api for my project's build, deployment functionalities ( in Local Machine ). I commited whole source (java project) via command prompt by following commands git add . git commit -a -m "Initial_Source" Here I get the commit id as cb96c685a5a4338f852a782631df8d1cf5dca21d git tag Initial_Source cb96c685a5a4338f852a782631df8d1cf5dca21d [cb96c685a5a4338f852a782631df8d1cf5dca21d is commitid] git push git push --tags but when i tried to get commit id via getPeeledObjectId() it is returning null my code is Ref tag = git.getRepository().getRef("Initial_Source"); Ref peeledRef = git

Does JGit API have all Git commands

こ雲淡風輕ζ 提交于 2019-12-06 15:08:06
I am trying to port a shell script to Java which contains a few Git commands which I have mostly managed to find in the JGit API. I have not, however, managed to find the remote or am commands, is this because the don't exist or I am just looking in the wrong place for them. If they don't exist is there another way to use them? There is no ready-to run counterpart for git remote and am in JGit, but it should be possible to implement (a subset of) them with reasonable effort. Those sub-commands of git remote that query or manipulate the config file can be emulated by directly accessing the

Is there a JGit method equivalent to git rev-parse --short?

我是研究僧i 提交于 2019-12-06 11:56:57
Does JGit include an implementation of git rev-parse --short ? I could not find one in perusing the documentation. There is no direct equivalent to git rev-parse in JGit. However, JGit provides API that may help to achieve what rev-parse does. ObjectId::isId() to determine if the given string represents a SHA-1 ObjectId::fromString() to create an ObjectId from a string To shorten a given object id, use ObjectId::abbreviate() The following example abbreviates the given SHA-1: ObjectId objectId = ObjectId.fromString( "fb808b5b01cdfaedda0bd1d304c7115ce959b286" ); AbbreviatedObjectId abbreviatedId

Determine number of commit ahead and behind using JGit

你。 提交于 2019-12-06 10:19:58
问题 On a GitHub project, when we go to any branches page, we can see graphs which describes commit ahead/behind numbers of a branch w.r.t. master. How can we determine those ahead behind numbers using JGit? I used BranchTrackingStatus class for this, but I'm getting BranchTrackingStatus object always null. Here is the code which I used private static Lis<Integer> getCounts(Repository repository, String branchName) throws IOException{ BranchTrackingStatus trackingStatus = BranchTrackingStatus.of

How do I produce every possible git-status?

流过昼夜 提交于 2019-12-06 05:51:55
问题 Background: We are currently using git for source management in a web app I am working on. There is an editor, and so there is also a web interface to git. One of our use cases is that people can ALSO manage their git repositories from the command line, so the web interface needs to be able to handle, in some way, any weird state it finds the repository in. Question: For testing, it would be great to get a git repository with a file in every possible state, so I could verify that all possible

JGit FetchCommand

风流意气都作罢 提交于 2019-12-06 04:26:22
I understand the concept of Git fetch. I would like to fetch objects through the FetchCommand class in the JGit API. I have a Git repository. For example C:\jGit\.git . I have cloned this repository. For example: C:\jGitClone\jGit\.git . I have cloned this repository again. For example C:\Users\user\Desktop\jGitClone\.git . Using the JGit API I have a Git class: Git git = new Git(repository); // this is the cloned repository. C:\jGitClone\jGit\.git How would I set the cloned repository which is on the desktop so when the fetch is called it knows to fetch into the this repository. I have looked