JGit checkout error while trying to examine repository with repodriller - git-checkout

I'm trying to run repodriller on all the commits of Jsoup. Each time I start the analysis of a new commit, I need to checkout the repository for that commit, so in my CommitVisitor, I execute this command scmRepository.getScm().checkout(commit.getHash());.
This command throws an exception 9/10 times, being
java.lang.RuntimeException:
org.eclipse.jgit.api.errors.CheckoutConflictException: Checkout
conflict with files:
src/test/resources/htmltests/news-com-au-home.html.gz
src/test/resources/htmltests/xwiki-1324.html.gz
src/test/resources/htmltests/xwiki-edit.html.gz
src/test/resources/htmltests/yahoo-jp.html.gz
Obviously, I have done no modifications on the repository, as I also cloned it fresh.
I highly doubt there's a problem in general with the approach because I've used the same technique on 10 java projects and only this one is problematic.
Is there a way to avoid the checkout of these files with JGit, or some alternative solution to the problem?

If possible, check if the same checkout would work with a regular Git command (git checkout or git switch)
A possible cause of a CheckoutConflictException is an unresolved merge conflict.
I would also check if you have the same file with different case (uper/lowercase).

Related

go get: Git settings ignored

I'm using Golang and GitLab CI, and I've got a GitLab CI configuration which works perfectly for 12 projects, but not for a 13th.
The problem I have is that I'm trying to go get some private repositories, which go get tries to run over HTTPS, which is turned off.
The solution, that works in the other repos, is this:
git config --global url."git#gitlab.my.site:".insteadOf "https://gitlab.my.site/"
However, in the runner for this one project, on the same GitLab, with the exact same config (except for the service name), this happens:
[...]
$ git config --global url."git#gitlab.my.site:".insteadOf "https://gitlab.my.site/"
$ cd ${APP_PATH}
$ go get
# cd .; git clone https://gitlab.my.site/group/project.git /go/src/gitlab.my.site/group/project
Cloning into '/go/src/gitlab.my.site/group/projects'...
GitLab: The project you were looking for could not be found.
fatal: Could not read from remote repository.
Why is it suddenly trying to clone over HTTPS? It happens in this one project only, consistently, but works in all the other ones. The only reason I can think about is that this one project uses a lot of different repos, rather than just one or two, but I have a hard time seing that this would be the actual issue.
How can I troubleshoot this?
Thanks.
Found the answer, and it's silly, and of course, my fault. I hadn't added the deploy key to the projects, of course rejecting the clones.
To fix the problem, in GitLab, go to the repository and then "Settings" > "Repository" and fold out "Deploy keys". There, make sure that the key you're trying to clone with is available and enabled.

SVN Merge automated shell script

I am working on shell script, which will automatically merge the different branches in SVN, but currently I stuck as am getting conflicts.
Can we resolve the conflicts by the script only?
No. You can go download a GUI & use it to resolve conflicts. One of the more popular GUIs is: https://tortoisesvn.net/downloads.html It can also be used with a file comparison tool like http://winmerge.org
If you want to try to do this automatically, you may have to figure out which of these options that you'd like to use. These 2 come from Apache's Resolving Tree Conflicts page:
svn resolve --accept=theirs
svn resolve --accept=mine
These 4 come from RedBean.com's SVN 1.8 Basic Work Cycle page:
svn resolve --accept=mine-conflict
svn resolve --accept=theirs-conflict
svn resolve --accept=mine-full
svn resolve --accept=theirs-full
svn resolve --accept=working

SVN: find files updated to nonexistence

I am writing a shell script which can store the actual state of a SVN working copy and restore it later, exactly as it was. Currently I have a problem with specific, rare combination of revisions of files and directories which seems to be undetectable.
Let's say that there is a repository with two revisions.
There are two cases:
Assume that foo is a file (or a directory) that exists only in revision 2. At the beginning the whole working copy is at revision 2. Then foo (and only foo) is updated to revision 1.
Assume that bar is a file (or a directory) that exists only in revision 1. At the beginning the whole working copy is at revision 1. Then bar (and only bar) is updated to revision 2.
The both cases are very similar but it seems that they have different solutions. In both cases the file (or directory) simply vanishes. However, output of command svn status contains no information about that.
How to create by a shell script a list of such files and directories?
There is one simple but bad solution. It is possible to use command svn list to get a list of files that should exist in current revision and compare it to the list of files that really exist.
This solution is unacceptable because it takes a lot of time and generates a big traffic to the server.
I posted the best answer that I can come up with. Still, it works only for the first case and has false-positives.
I once attempted to do the same thing that you're doing, and I hit so many corner cases that I eventually went a completely different direction. Instead of using a script, I used a local git repository.
Check out a working copy from the Subversion repository, then create a local git repository in that folder using git init. Add the entire contents of your Subversion working copy to the git repository - including the .svn metadata directories - using git add followed by a git commit. Git is now keeping track of your working copy plus all of the Subversion metadata associated with it. My current git repository has 5 different branches, each based off of a different Subversion revision and containing different sets of changes that haven't been committed to the Subversion repository yet. The git repository makes it easy to switch back and forth between them, and Subversion works as if they were all separate working copies. Even for large working copies, git does a good job at storing contents efficiently and switching between branches quickly.
Note that this is different than the git svn command, which is git's method of directly interfacing with a Subversion repository. I found git svn to be more complicated to use and easier to break things. Wrapping a normal Subversion working copy in a git repository allowed me to still do all of my repository operations using Subversion, and only required me to learn a few basic git commands (add, commit, branch, checkout, etc). It's a bit easier for someone who is experienced with Subversion and new to git; git svn is more geared towards someone who is experienced with git and stuck with a Subversion repository.
I found partially solution for the first case.
svn status -u | grep '^........\*........ ' | cut -c 22-
This code shows all files that exist in head revision and do not exists in current one. This finds files and directories from first case. However, it generates false-positives, when a file is removed when the parent directory (which still exists) is updated to lower revision.

Integrating GitLab with TeamCity

Since GitLab 7.6, or thereabouts, there is a new option to use TeamCity directly from GitLab projects. In the setup there is this message:
The build configuration in Teamcity must use the build format number
%build.vcs.number% you will also want to configure monitoring of all
branches so merge requests build, that setting is in the vsc root
advanced settings.
I'm not sure how this works. Lets say I have a repository Foo.
I have setup a build on TeamCity to listen to Foo with branch specification: +:refs/pull/*/merge
I then fork Foo in gitlab as FooFork, make a change, then request a merge FooFork -> Foo.
But nothing happens to test this merge, which is what I was expecting GitLab to do. If I accept the merge than the build server jumps into action (immediately) and builds twice (master and /ref/master).
I've also set the build configuration to use exactly: %build.vcs.number% as the build number as prescribed, but gitlab doesn't seem to give me any information about the build result.
So I'm a bit confused really as to what exactly this GitLab -> TeamCity integration is supposed to do and whether I'm doing wrong.
I'm currently running GitLab 7.9 and TeamCity 8.1.4
Update:
Seems this use case was not supported prior to version 8 - https://github.com/gitlabhq/gitlabhq/issues/7240
I'm running GitLab 8.0.2 and TeamCity 9.1.1 and am able to run CI builds on branches and merge requests.
I trigger CI builds for specific branches by setting a VCS trigger together with the branch specification +:refs/heads/(xyz*) where xyz is the string for our ticket system prefix since all active branches need to be named after an entry in our issue tracker.
I trigger builds for merge requests via the branch specification +:refs/(merge-requests/*)
Everything works as as expected and lets us know the status of all feature / bug branches and merge requests automatically.
Thanks to Rob's comment linking to the GitLab 8 release notes entry on the merge request spec.
Same problem here. There might be another way, I'm evaluating right now. Since there's no direct way of getting the merged state from the target MR, you have to build it on your own:
IMO there's the following todos
1.) init a bare repo $ git init
2.) add your target repo $ git remote add origin git#your-repo:<origin.group>/<origin.repo>.git
3.) add the remote/feature/to-merge's $ git remote add target git#your-repo:<feature.group>/<feature.repo>.git
4.) checkout your feature branch $ git checkout -b <feature.branch> feature/<feature.branch>
5.) checkout your original branch $ git checkout -b <origin.branch> origin/<origin.branch>
6.) Rebase feature into your original branch $ git rebase <feature.branch>
As stated here [1], GitLab-CE can fire an event on creation of a merge-request,
so all you have to do is building some meta, that can evaluate the WebHooks.
[1] http://doc.gitlab.com/ce/web_hooks/web_hooks.html#merge-request-events

Resolving SVN tree conflicts in Xcode

I'm trying to resolve a tree conflict from SVN in Xcode. From the answer here The operation could not be performed because "PROJECTNAME" has one or more tree conflicts I should simply resolve the conflict using the command-line. No problem, I've got some experience with SVN command line, so I do exactly that
svn merge ^/project/trunk
svn resolve --accept working conflictedFile1.m
svn resolve --accept working conflictedFile2.m
svn resolve --accept working conflictedFile3.m
svn ci . -m "merge: from trunk"
Then I go back to Xcode and just to make sure everything is happy and try to test that everything "took". I do "Source Control -> Update" and then "Source Control -> project -> Merge from Branch … -> trunk" and I again get the stupid error message: "The operation could not be performed because of one or more tree conflicts." and the additional message "The files conflictedFile1.m, conflictedFile2.m, and conflictedFile3.m had a tree conflict."
In fact my question is not how to resolve this tree conflict, but how do I tell Xcode that I already did resolve the conflict? Is there some out-of-date svn database somewhere that I need to refresh/delete? Did I resolve this wrong in the first place?
Bonus question:
It would be really nice to continue to use Xcode's builtin SVN features to do merges, etc. I can use the command line but I'd really rather not for things like merges, when I have a builtin merge-diff tool in my IDE. In general, any advice on using SVN in Xcode properly is greatly appreciated. Therefore, if there is any specific advice anybody can give me to prevent this from happening in the future, I'll be very happy.
What I did was:
(1) branch from trunk to Branch1
(2) add a file on Branch1 (as well as other edits)
(3) branch from Branch1 to Branch2
(4) make edits (no new files)
(5) merge from Branch2 to trunk
(6) merge from trunk to Branch1 -> tree conflict with the files originally created here

Resources