Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 367807

Summary: [github] Compare not exposed via CommitService
Product: [Technology] EGit Reporter: Taylor Leese <tleese22>
Component: CoreAssignee: Kevin Sawicki <kevin>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: tleese22
Version: unspecified   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Taylor Leese CLA 2012-01-03 19:56:06 EST
Build Identifier: 

The compare endpoint defined below for comparing commits is not exposed via the CommitService.

GET /repos/:user/:repo/compare/:base...:head 
(see http://developer.github.com/v3/repos/commits/)

It appears that this may be missing from the CommitService (https://github.com/eclipse/egit-github/blob/master/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/CommitService.java).

The version I'm using is below:

    <dependency>
      <groupId>org.eclipse.mylyn.github</groupId>
      <artifactId>org.eclipse.egit.github.core</artifactId>
      <version>1.1.2</version>
    </dependency>


Reproducible: Always

Steps to Reproduce:
* Missing from egit-github CommitService
Comment 1 Kevin Sawicki CLA 2012-01-03 20:41:05 EST
Proposed fix pushed to: http://egit.eclipse.org/r/#change,4917
Comment 2 Kevin Sawicki CLA 2012-01-05 12:42:20 EST
This had been fixed in master in commit  728081f97dd6a64cba68794101a18fac983f8e7e

CommitService.compare is the new method.

There is a 1.2.1-SNAPSHOT version with this fix available here: https://oss.sonatype.org/index.html#nexus-search;quick~org.eclipse.egit.github.core
Comment 3 Taylor Leese CLA 2012-01-05 12:43:42 EST
Awesome. Thanks for the quick turnaround. I will give it a try today.
Comment 4 Taylor Leese CLA 2012-01-05 19:37:09 EST
After getting back a RepositoryCommitCompare and calling getFile, what is the best way to get the raw file specified by CommitFile.getRawUrl. I'm not clear on how to do this with the SDK or if it's possible? I tried making an OAuth request to the raw url, but I've been getting 406's so not sure if I'm doing something wrong or if it's not possible? Basically, I want to get the RepositoryCommitCompare and get the raw files for all changed files.
Comment 5 Kevin Sawicki CLA 2012-01-05 19:42:51 EST
You can use a DataService and call:

DataService.getBlob(IRepositoryIdProvider repository, String sha)

with the SHA-1 returned from CommitFile.getSha

The contents of the Blob object returned will be base64 encoded and you can call:

EncodingUtils.fromBase64 to get the raw content as a byte array
Comment 6 Taylor Leese CLA 2012-01-05 19:50:37 EST
Actually, that was exactly what I tried initially, but it seems to give back metadata regarding the file rather than the actual raw file. For example, I get something back like this (update is the commit message):

tree ab700454826a8c36b8fa9443d4edd2d28b263a7f
parent 04b6fe63be718cea4ffa2b6af98e3cb7714714a3
author Taylor Leese <taylor@stackmob.com> 1325209880 -0800
committer Taylor Leese <taylor@stackmob.com> 1325209880 -0800

update
Comment 7 Kevin Sawicki CLA 2012-01-05 19:51:54 EST
Are you sure you used the sha from the CommitFile and not the RepsitoryCommit?
Comment 8 Taylor Leese CLA 2012-01-05 19:58:14 EST
Yes, I'm using the CommitFile. Code is something like this (scala):

val compare = commitService.compare(repo, c, repoCommit.getSha)
val files = compare.getFiles
val rawList = files map { f => (f.getFilename, dataService.getBlob(repo, f.getSha)) }
Comment 9 Kevin Sawicki CLA 2012-01-05 19:59:32 EST
Is the repository you are using public and could you provide the URL for the the blob in question?
Comment 10 Taylor Leese CLA 2012-01-05 20:06:47 EST
The repository is actually private (stackmob org).

Blob URL: 
https://github.com/stackmob/github-integration-testing/blob/fa7c1b1f0e5d8167d3bdace3d9d2a94499bac79b/README