jgit

jgit how can i get all the commits that occurred between two dates

心已入冬 提交于 2019-12-06 01:52:01
Or just all the commits that occurred between two dates? In SVN, you could do something like svn diff -r{date}:{date} to do it! You can take example of this JGit test class RevWalkFilterTest.java : Date since = getClock(); Date until = getClock(); RevFilter between = CommitTimeRevFilter.between(since, until); It uses the class org.eclipse.jgit.revwalk.filter.CommitTimeRevFilter . 来源: https://stackoverflow.com/questions/19580762/jgit-how-can-i-get-all-the-commits-that-occurred-between-two-dates

Configuring known_hosts in jgit

两盒软妹~` 提交于 2019-12-06 01:37:29
问题 Using jgit with gitolite for source control, I have an application that generates certain code on command and which we want to be committed to source control. The goal is to pull with a fast forward, commit the new code, and then push it. I have the following method: private void commitToGitRepository(String updateComment, Config config) throws IOException, NoFilepatternException, GitAPIException { if(git == null) { git = Git.open(new File(config.getDpuCheckoutDir())); } PullCommand pull =

Gerrit replicating to gitolite fails

两盒软妹~` 提交于 2019-12-06 01:32:30
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 ~/.ssh/known_hosts the replication plugin fails with the following stacktrace [2017-08-02 13:08:55,194]

How to Check if A Git Clone Has Been Done Already with JGit

老子叫甜甜 提交于 2019-12-05 21:28:36
I learning git and using JGit to access Git repos from java code. Git by default does not allow to clone to a non-empty directory. How do we figure out that a git clone has already been done for a particular git repo in the local machine so that we can only do a Git pull subsequently? Currently I'm using this approach: if a root folder is existing in the specified location clone has been done pull else clone Not sure if this is correct though. Any better ideas? Thank you. This is the approach I used, as specified in the Jgit mailing list: Check if a git repository is existing: if

JGit how do i get the SHA1 from a RevCommit?

亡梦爱人 提交于 2019-12-05 16:28:02
问题 This seems like an idiotic question, but I can't find documentation on it anywhere. How do I get a the SHA1 of a RevCommit object? 回答1: RevCommit inherits from AnyObjectId which has a getName function. getName public final String getName() Returns : string form of the SHA-1, in lower case hexadecimal. 来源: https://stackoverflow.com/questions/22276456/jgit-how-do-i-get-the-sha1-from-a-revcommit

Retrieving Commit Message Log from Git Using JGit

邮差的信 提交于 2019-12-05 14:27:21
I just want to retrieve the commitlog from Git repository that has messages for all the commit you've done on a specific repopsitory. I had found some code snippets for achieve this and ends with an exception. try { FileRepositoryBuilder builder = new FileRepositoryBuilder(); Repository repo = builder.setGitDir(new File("https://github.com/name/repository.git")).readEnvironment().findGitDir().build(); RevWalk walk =new RevWalk(repo); ObjectId head = repo.resolve(Constants.HEAD); RevCommit commit =walk.parseCommit(head); Git git =new Git(repo); Iterable<RevCommit> gitLog = git.log().call();

JGit Check if a branch is checked out

强颜欢笑 提交于 2019-12-05 11:56:10
I am working on a project using JGit. I managed to delete a branch, but I also want to check if that branch is checked out or not. I found a variable in CheckoutCommand but it is private: private boolean isCheckoutIndex() { return startCommit == null && startPoint == null; } No public method returns what I want. When I use the command below on a checked out branch it returns an error that the branch cannot be deleted, so I want to check first if is checked out or not. git.branchDelete().setForce(true).setBranchNames(branchName).call(); Repository::getFullBranch() returns the full name (e.g.

How to set tracking on an existing repo to a remote repo with ngit (or jgit)?

可紊 提交于 2019-12-05 10:34:41
I am working on a gui based helper utility that will: Init a local repo, Init (bare) a remote repo Add .gitignore based on a project type Commit all the files locally Add a remote repo to the local config Push master to the remote repo Create a develop branch and push it to master All this is done without git installed by using ngit (.NET port of jgit). But I can't figure out how to setup tracking to track master to origin/master and develop to origin/develop using just ngit . I can do it easily with git branch --set-upstream master origin/master However, I was hoping to avoid the dependency

eclipse: “re-indexing repository workspace” or “Computing Git status for repository workspace”

混江龙づ霸主 提交于 2019-12-05 10:21:58
I am using eclipse Juno, and yesterday I noticed my computer was getting very hot. I checked the CPU usage to see it was at 100%. Eclipse was the culprit, busy "re-indexing repository workspace". When after half an hour it hadn't finished and my machine was nearly melting, I searched and found these similar problems: Re-indexing repository loop - not Maven Eclipse hangs on "Re-indexing (fully) repository {username}" Thing is I'm not using git. And by the sounds of things I don't want to since it's going to eat all my CPU. I removed ~/git, deleted a project I have which uses git, checked for

List branches of a git remote repo without cloning it

六眼飞鱼酱① 提交于 2019-12-05 04:45:28
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 There is the LsRemoteCommand to list the branches of a remote repository. To obtain the command, use either Git.wrap( repo ).lsRemote() or Git.lsRemoteRepository() The statically created LsRemoteCommand has its