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

Bug 371408

Summary: Id should not have trailing slash in git api
Product: [ECD] Orion Reporter: John Arthorne <john.arthorne>
Component: GitAssignee: Tomasz Zarna <tomasz.zarna>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: P4 CC: johnjbarton, Szymon.Brandys
Version: 0.4   
Target Milestone: 0.5 M1   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description John Arthorne CLA 2012-02-13 14:02:19 EST
I20120212-2230

In http://wiki.eclipse.org/Orion/Server_API/Git_API#Getting_the_list_of_repositories it says response has the form:

 {
   "BranchLocation": "http://localhost:8080/gitapi/branch/file/u/",
   "ConfigLocation": "http://localhost:8080/gitapi/config/clone/file/u/",
   "ContentLocation": "http://localhost:8080/file/u/",
   "GitUrl": "ssh://sfranklin@git.eclipse.org/gitroot/e4/org.eclipse.orion.client.git",
   "HeadLocation": "http://localhost:8080/gitapi/commit/HEAD/file/u/",
   "Id": "u/",
   "Location": "http://localhost:8080/gitapi/clone/file/u/",
   "Name": "sfranklin",
   "RemoteLocation": "http://localhost:8080/gitapi/remote/file/u/"
 },

I think the trailing slash on the Id element is wrong. This is not a hierarchical element so it shouldn't have a slash. On Workspace and Project resource for example there is no such trailing slash.
Comment 1 John J. Barton CLA 2012-02-13 14:08:51 EST
In case you need to know, the slash is also in the response, not just in the documentation.
Comment 2 Szymon Brandys CLA 2012-02-14 04:16:41 EST
Git elements' locations contain .../file/[path] part which is derived from file locations in Orion workspace. Git locations may point at the root of a repo like http://localhost:8080/gitapi/remote/file/u/, but also at files inside e.g. http://localhost:8080/gitapi/remote/file/u/myFolder or http://localhost:8080/gitapi/remote/file/u/myFolder/myFile.txt.

When you use such Git location, you could for instance get a log narrowed to folder or file.

So there is a hierarchy and GET on http://localhost:8080/gitapi/remote/file/u/ could also return children that contain Git locations narrowed to this particular child.

Tomek, what do you think?
Comment 3 John Arthorne CLA 2012-02-14 08:47:11 EST
So you have some responses where the id is something like "a/b/c" ? What does the id mean in that case... is it used for something on the client?
Comment 4 John J. Barton CLA 2012-02-14 10:27:45 EST
Perhaps the solution is a new property "projectId" that will be character identical to the value of one of the project ids.    

In my case I need to find the project that matches the repo.
Comment 5 Szymon Brandys CLA 2012-02-15 04:48:54 EST
(In reply to comment #4)
> In my case I need to find the project that matches the repo.

You may clone/init a repo in a subfolder, then its 'Id' would be something like 'projectId/subFolder'. So clone 'Id' can't be directly mapped to top-level folder 'Id'.
BTW in comment 2 I confused clone 'Id' with 'Location. As I said the trailing slash in 'Location' is justified, but I'm not sure about clone 'Id'.
Comment 6 Tomasz Zarna CLA 2012-02-15 05:42:01 EST
(In reply to comment #3)
> So you have some responses where the id is something like "a/b/c" ? What does
> the id mean in that case...

An id like that would mean that a clone has been created in the "c" folder. However, if this is part of a Location, and the clone has been created in the "a" folder calling Git Log for "a/b/c" will return a list of commits for the "c" file only. In other words, you have to remember about two things:
* clones don't have to be located in top level folders (Szymon already mentioned that in comment 5)
* some git ops accept full path in the Location to narrow their scope ie. Log, Status, Diff, ...

Rewinding the discussion to comment 0, I do agree the trailing slash on the Id element looks bad. Is it something we would like to have fixed for .4?
Comment 7 Szymon Brandys CLA 2012-02-15 07:15:56 EST
Why don't remove 'Id' from the clone JSON? I can't find any Orion Git API that uses it. All methods uses clone 'Location' what is the right thing.
JJ, if you want to find a workspace location for a clone, you could use clone 'ContentLocation' instead of mapping clone and project Ids.
Comment 8 Tomasz Zarna CLA 2012-03-19 06:42:42 EDT
The property has been removed in 56d328dbc35ca4eda2b7e7c0d74e3efd474fc484. No side effects noticed in the UI so far.