Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Orion/Server API/Git API"
(→Creating a branch) |
m (→Adding a new remote) |
||
(174 intermediate revisions by the same user not shown) | |||
Line 10: | Line 10: | ||
!width="25%"|POST | !width="25%"|POST | ||
!width="25%"|DELETE | !width="25%"|DELETE | ||
+ | |- | ||
+ | ! blame | ||
+ | | [[#Getting blame result from HEAD]]<br>[[#Getting blame result from commit]] || || || | ||
|- | |- | ||
! branch | ! branch | ||
Line 18: | Line 21: | ||
|- | |- | ||
! commit | ! commit | ||
− | | [[#Listing commits]]<br>[[#Getting commit metadata]]<br>[[#Getting file content in a commit]]<br>[[#Getting a file content from HEAD]]<br>[[#Getting file content in a commit]] || [[#Tagging a commit]] || [[#Committing all files in index]]<br>[[#Amending a commit]]<br>[[#Committing a single file]]<br>[[#Merging changes from a remote to HEAD]]<br>[[#Cherry-picking a commit]] || [[#git rm]] | + | | [[#Listing commits]]<br>[[#Listing commits revision or named commits]]<br>[[#Getting commit metadata]]<br>[[#Getting file content in a commit]]<br>[[#Getting a file content from HEAD]]<br>[[#Getting file content in a commit]] || [[#Tagging a commit]] || [[#Committing all files in index]]<br>[[#Amending a commit]]<br>[[#Committing a single file]]<br>[[#Merging changes from a remote to HEAD]]<br>[[#Cherry-picking a commit]] || [[#git rm]] |
|- | |- | ||
! config | ! config | ||
Line 47: | Line 50: | ||
* [[#Unstaging all files in the index]] | * [[#Unstaging all files in the index]] | ||
* [[#Getting a file content from index]] | * [[#Getting a file content from index]] | ||
+ | |||
+ | === git blame === | ||
+ | * [[#Getting blame result from HEAD]] | ||
+ | * [[#Getting blame result from commit]] | ||
=== git branch === | === git branch === | ||
Line 95: | Line 102: | ||
=== git log === | === git log === | ||
* [[#Listing commits]] | * [[#Listing commits]] | ||
+ | * [[#Listing commits between two named commits]] | ||
* [[#Getting commit metadata]] | * [[#Getting commit metadata]] | ||
* [[#Getting file content in a commit]] | * [[#Getting file content in a commit]] | ||
Line 146: | Line 154: | ||
| method = GET | | method = GET | ||
| overview = To get the list of repositories send a GET request to the git clone location. | | overview = To get the list of repositories send a GET request to the git clone location. | ||
− | | reqhead = /gitapi/clone/workspace/ | + | | reqhead = /gitapi/clone/workspace/{:workspace_id}/ |
| reqbody = | | reqbody = | ||
| resphead = 200 OK | | resphead = 200 OK | ||
Line 157: | Line 165: | ||
"GitUrl": "ssh://sfranklin@git.eclipse.org/gitroot/e4/org.eclipse.orion.client.git", | "GitUrl": "ssh://sfranklin@git.eclipse.org/gitroot/e4/org.eclipse.orion.client.git", | ||
"HeadLocation": "http://localhost:8080/gitapi/commit/HEAD/file/u/", | "HeadLocation": "http://localhost:8080/gitapi/commit/HEAD/file/u/", | ||
− | |||
"Location": "http://localhost:8080/gitapi/clone/file/u/", | "Location": "http://localhost:8080/gitapi/clone/file/u/", | ||
"Name": "sfranklin", | "Name": "sfranklin", | ||
Line 167: | Line 174: | ||
"ContentLocation": "http://localhost:8080/file/q0/", | "ContentLocation": "http://localhost:8080/file/q0/", | ||
"HeadLocation": "http://localhost:8080/gitapi/commit/HEAD/file/q0/", | "HeadLocation": "http://localhost:8080/gitapi/commit/HEAD/file/q0/", | ||
− | |||
"Location": "http://localhost:8080/gitapi/clone/file/q0/", | "Location": "http://localhost:8080/gitapi/clone/file/q0/", | ||
"Name": "bug349480", | "Name": "bug349480", | ||
Line 181: | Line 187: | ||
| method = POST | | method = POST | ||
| overview = To create a clone send a POST request to the git clone location. | | overview = To create a clone send a POST request to the git clone location. | ||
− | | reqhead = / | + | | reqhead = /gitapi/clone/ |
| reqbody = | | reqbody = | ||
{ | { | ||
+ | "Location" : "/workspace/{workspace_id}", | ||
"GitUrl" : "{git repo url}", | "GitUrl" : "{git repo url}", | ||
"GitSshKnownHost" : "{git ssh known host}", | "GitSshKnownHost" : "{git ssh known host}", | ||
Line 209: | Line 216: | ||
| method = POST | | method = POST | ||
| overview = To init a git repository send a POST request to the git clone location. JSON data '''cannot''' contain GitUrl field, as it indicates that desired operation is cloning of a repository. | | overview = To init a git repository send a POST request to the git clone location. JSON data '''cannot''' contain GitUrl field, as it indicates that desired operation is cloning of a repository. | ||
− | | reqhead = / | + | | reqhead = /gitapi/clone/ |
| reqbody = | | reqbody = | ||
{ | { | ||
− | "Name" : " | + | "Name" : "{repo_name}", |
− | "Location" : "/workspace/ | + | "Location" : "/workspace/{workspace_id}", |
− | " | + | "GitMail" : "{committer e-mail address}", |
+ | "GitName" : "{committer name}" | ||
} | } | ||
| resphead = 201 CREATED | | resphead = 201 CREATED | ||
| respbody = | | respbody = | ||
{ | { | ||
− | "Location": "http://localhost:8080/git/clone/file/ | + | "Location": "http://localhost:8080/git/clone/file/user-OrionContent/repo" |
} | } | ||
| explain = The response contains the location of the initialized git repository. Call Get on this location to obtain more repository details. Request body can contain either "Name" and "Location" fields (a new project with git repository will be created in the given workspace) or "Path" field only (git repository will be created in the given project). | | explain = The response contains the location of the initialized git repository. Call Get on this location to obtain more repository details. Request body can contain either "Name" and "Location" fields (a new project with git repository will be created in the given workspace) or "Path" field only (git repository will be created in the given project). | ||
Line 229: | Line 237: | ||
| method = DELETE | | method = DELETE | ||
| overview = To delete a clone send a DELETE request to the git clone location. | | overview = To delete a clone send a DELETE request to the git clone location. | ||
− | | reqhead = / | + | | reqhead = /gitapi/clone/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
| resphead = 200 OK | | resphead = 200 OK | ||
Line 241: | Line 249: | ||
| method = GET | | method = GET | ||
| overview = To get the list of repository options send a GET request to the git config location. | | overview = To get the list of repository options send a GET request to the git config location. | ||
− | | reqhead = /gitapi/config/clone/file/ | + | | reqhead = /gitapi/config/clone/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
| resphead = 200 OK | | resphead = 200 OK | ||
Line 249: | Line 257: | ||
"Key": "core.repositoryformatversion", | "Key": "core.repositoryformatversion", | ||
"Location": "http://localhost:8080/gitapi/config/core.repositoryformatversion/clone/file/A/", | "Location": "http://localhost:8080/gitapi/config/core.repositoryformatversion/clone/file/A/", | ||
− | "Value": "0" | + | "Value": ["0"] |
}, | }, | ||
{ | { | ||
"Key": "core.filemode", | "Key": "core.filemode", | ||
"Location": "http://localhost:8080/gitapi/config/core.filemode/clone/file/A/", | "Location": "http://localhost:8080/gitapi/config/core.filemode/clone/file/A/", | ||
− | "Value": "false" | + | "Value": ["false"] |
}, | }, | ||
{ | { | ||
"Key": "core.logallrefupdates", | "Key": "core.logallrefupdates", | ||
"Location": "http://localhost:8080/gitapi/config/core.logallrefupdates/clone/file/A/", | "Location": "http://localhost:8080/gitapi/config/core.logallrefupdates/clone/file/A/", | ||
− | "Value": "true" | + | "Value": ["true"] |
}, | }, | ||
{ | { | ||
"Key": "core.autocrlf", | "Key": "core.autocrlf", | ||
"Location": "http://localhost:8080/gitapi/config/core.autocrlf/clone/file/A/", | "Location": "http://localhost:8080/gitapi/config/core.autocrlf/clone/file/A/", | ||
− | "Value": "false" | + | "Value": ["false"] |
}, | }, | ||
{ | { | ||
"Key": "user.name", | "Key": "user.name", | ||
"Location": "http://localhost:8080/gitapi/config/user.name/clone/file/A/", | "Location": "http://localhost:8080/gitapi/config/user.name/clone/file/A/", | ||
− | "Value": "John" | + | "Value": ["John"] |
}, | }, | ||
{ | { | ||
"Key": "user.email", | "Key": "user.email", | ||
"Location": "http://localhost:8080/gitapi/config/user.email/clone/file/A/", | "Location": "http://localhost:8080/gitapi/config/user.email/clone/file/A/", | ||
− | "Value": "john@email.com" | + | "Value": ["john@email.com"] |
} | } | ||
]} | ]} | ||
Line 285: | Line 293: | ||
| method = GET | | method = GET | ||
| overview = To get the repository option send a GET request to the git config option location. | | overview = To get the repository option send a GET request to the git config option location. | ||
− | | reqhead = /gitapi/config/user.name/clone/file/ | + | | reqhead = /gitapi/config/user.name/clone/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
| resphead = 200 OK | | resphead = 200 OK | ||
Line 291: | Line 299: | ||
{ | { | ||
"Key": "user.name", | "Key": "user.name", | ||
− | "Location": "http://localhost:8080/gitapi/config/user.name/clone/file/ | + | "Location": "http://localhost:8080/gitapi/config/user.name/clone/file/user-OrionContent/repo/", |
− | "Value": "John" | + | "Value": ["John"] |
} | } | ||
| explain = The response contains the repository option key, value and location. | | explain = The response contains the repository option key, value and location. | ||
Line 302: | Line 310: | ||
| method = PUT | | method = PUT | ||
| overview = To update repository option send a PUT request to the git config option location. POST also can be used, see [[#Setting repository option]]. | | overview = To update repository option send a PUT request to the git config option location. POST also can be used, see [[#Setting repository option]]. | ||
− | | reqhead = /gitapi/config/user.name/clone/file/ | + | | reqhead = /gitapi/config/user.name/clone/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
{ | { | ||
Line 311: | Line 319: | ||
{ | { | ||
"Key": "user.name", | "Key": "user.name", | ||
− | "Location": "http://localhost:8080/gitapi/config/user.name/clone/file/ | + | "Location": "http://localhost:8080/gitapi/config/user.name/clone/file/user-OrionContent/repo/", |
− | "Value": "John" | + | "Value": ["John"] |
} | } | ||
| explain = The response contains the repository option key, value and location. | | explain = The response contains the repository option key, value and location. | ||
Line 322: | Line 330: | ||
| method = POST | | method = POST | ||
| overview = To set a new repository option send a POST request to the git config location. | | overview = To set a new repository option send a POST request to the git config location. | ||
− | | reqhead = /gitapi/config/clone/file/ | + | | reqhead = /gitapi/config/clone/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
{ | { | ||
Line 332: | Line 340: | ||
{ | { | ||
"Key": "user.name", | "Key": "user.name", | ||
− | "Location": "http://localhost:8080/gitapi/config/user.name/clone/file/ | + | "Location": "http://localhost:8080/gitapi/config/user.name/clone/file/user-OrionContent/repo/", |
− | "Value": "Alice" | + | "Value": ["Alice"] |
} | } | ||
| explain = The response contains the repository option key, value and location. | | explain = The response contains the repository option key, value and location. | ||
Line 343: | Line 351: | ||
| method = DELETE | | method = DELETE | ||
| overview = To unset repository option send a DELETE request to the git config option location. | | overview = To unset repository option send a DELETE request to the git config option location. | ||
− | | reqhead = /gitapi/config/user.name/clone/file/ | + | | reqhead = /gitapi/config/user.name/clone/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
| resphead = 200 OK | | resphead = 200 OK | ||
Line 355: | Line 363: | ||
| method = GET | | method = GET | ||
| overview = To retrieve file content kept in HEAD. Send a GET request to the git commit location. | | overview = To retrieve file content kept in HEAD. Send a GET request to the git commit location. | ||
− | | reqhead = / | + | | reqhead = /gitapi/commit/HEAD/file/{:workspace_id}/{:repo_dir}/file.txt |
| resphead = 200 OK | | resphead = 200 OK | ||
Content-Type: text/plain | Content-Type: text/plain | ||
Line 369: | Line 377: | ||
| method = POST | | method = POST | ||
| overview = To commit all files in index. Send a POST request to the git commit location. | | overview = To commit all files in index. Send a POST request to the git commit location. | ||
− | | reqhead = / | + | | reqhead = /gitapi/commit/HEAD/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = { | | reqbody = { | ||
"Message" : "fixing bug 349827" | "Message" : "fixing bug 349827" | ||
Line 381: | Line 389: | ||
"CommitterEmail": "Tomasz.Zarna@pl.ibm.com", | "CommitterEmail": "Tomasz.Zarna@pl.ibm.com", | ||
"CommitterName": "Tomasz Zarna", | "CommitterName": "Tomasz Zarna", | ||
− | "ContentLocation": "http://localhost:8080/gitapi/commit/1fe0d121457ec1fc61d86e497576972443cdb14a/file/ | + | "ContentLocation": "http://localhost:8080/gitapi/commit/1fe0d121457ec1fc61d86e497576972443cdb14a/file/user-OrionContent/repo/?parts=body", |
− | "DiffLocation": "http://localhost:8080/gitapi/diff/1fe0d121457ec1fc61d86e497576972443cdb14a/file/ | + | "DiffLocation": "http://localhost:8080/gitapi/diff/1fe0d121457ec1fc61d86e497576972443cdb14a/file/user-OrionContent/repo/", |
"Diffs": [{ | "Diffs": [{ | ||
"ChangeType": "MODIFY", | "ChangeType": "MODIFY", | ||
− | "DiffLocation": "http://localhost:8080/gitapi/diff/c47c36518cd8aaf01b84afa55cf9a75badc882d9..1fe0d121457ec1fc61d86e497576972443cdb14a/file/ | + | "DiffLocation": "http://localhost:8080/gitapi/diff/c47c36518cd8aaf01b84afa55cf9a75badc882d9..1fe0d121457ec1fc61d86e497576972443cdb14a/file/user-OrionContent/repo/folder/file.txt", |
"NewPath": "folder/file.txt", | "NewPath": "folder/file.txt", | ||
"OldPath": "folder/file.txt", | "OldPath": "folder/file.txt", | ||
"Type": "Diff" | "Type": "Diff" | ||
}], | }], | ||
− | "Location": "http://localhost:8080/gitapi/commit/1fe0d121457ec1fc61d86e497576972443cdb14a/file/ | + | "Location": "http://localhost:8080/gitapi/commit/1fe0d121457ec1fc61d86e497576972443cdb14a/file/user-OrionContent/repo/", |
"Message": "fixing bug 349827", | "Message": "fixing bug 349827", | ||
"Name": "1fe0d121457ec1fc61d86e497576972443cdb14a", | "Name": "1fe0d121457ec1fc61d86e497576972443cdb14a", | ||
Line 404: | Line 412: | ||
| method = POST | | method = POST | ||
| overview = To amend the last commit. Send a POST request to the git commit location. | | overview = To amend the last commit. Send a POST request to the git commit location. | ||
− | | reqhead = /gitapi/commit/HEAD/file/ | + | | reqhead = /gitapi/commit/HEAD/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = { | | reqbody = { | ||
− | "Message" : "{ | + | "Message" : "{amended commit message}", |
− | "Amend" : "true" | + | "Amend" : "true", |
+ | "ChangeId" : false, | ||
+ | "AuthorName" : "{author name}", | ||
+ | "AuthorEmail" : "{author email}", | ||
+ | "CommitterName" : "{committer name}", | ||
+ | "CommitterEmail" : "{committer email}", | ||
+ | "persist" : false | ||
} | } | ||
| resphead = 200 OK | | resphead = 200 OK | ||
Line 420: | Line 434: | ||
| method = POST | | method = POST | ||
| overview = To commit a single. Send a POST request to the git commit location of that file. | | overview = To commit a single. Send a POST request to the git commit location of that file. | ||
− | | reqhead = / | + | | reqhead = /gitapi/commit/HEAD/file/{:workspace_id}/{:repo_dir}/{:file_path} |
| reqbody = { | | reqbody = { | ||
"Message" : "fixing bug 349827" | "Message" : "fixing bug 349827" | ||
Line 432: | Line 446: | ||
"CommitterEmail": "Tomasz.Zarna@pl.ibm.com", | "CommitterEmail": "Tomasz.Zarna@pl.ibm.com", | ||
"CommitterName": "Tomasz Zarna", | "CommitterName": "Tomasz Zarna", | ||
− | "ContentLocation": "http://localhost:8080/gitapi/commit/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/ | + | "ContentLocation": "http://localhost:8080/gitapi/commit/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/user-OrionContent/repo/test.txt?parts=body", |
− | "DiffLocation": "http://localhost:8080/gitapi/diff/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/ | + | "DiffLocation": "http://localhost:8080/gitapi/diff/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/user-OrionContent/repo/test.txt", |
"Diffs": [{ | "Diffs": [{ | ||
"ChangeType": "MODIFY", | "ChangeType": "MODIFY", | ||
− | "DiffLocation": "http://localhost:8080/gitapi/diff/1fe0d121457ec1fc61d86e497576972443cdb14a..91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/ | + | "DiffLocation": "http://localhost:8080/gitapi/diff/1fe0d121457ec1fc61d86e497576972443cdb14a..91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/user-OrionContent/repo/test.txt", |
"NewPath": "test.txt", | "NewPath": "test.txt", | ||
"OldPath": "test.txt", | "OldPath": "test.txt", | ||
"Type": "Diff" | "Type": "Diff" | ||
}], | }], | ||
− | "Location": "http://localhost:8080/gitapi/commit/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/ | + | "Location": "http://localhost:8080/gitapi/commit/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/user-OrionContent/repo/test.txt", |
"Message": "fixing bug 349827", | "Message": "fixing bug 349827", | ||
"Name": "91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9", | "Name": "91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9", | ||
Line 455: | Line 469: | ||
| method = POST | | method = POST | ||
| overview = To merge changes from a remote to HEAD send a POST request to the git commit location. | | overview = To merge changes from a remote to HEAD send a POST request to the git commit location. | ||
− | | reqhead = /gitapi/commit/HEAD/file/ | + | | reqhead = /gitapi/commit/HEAD/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
| resphead = 200 OK | | resphead = 200 OK | ||
| reqbody = | | reqbody = | ||
{ | { | ||
− | "Merge" : " | + | "Merge" : "{refId}" |
} | } | ||
| respbody = | | respbody = | ||
Line 472: | Line 486: | ||
| method = POST | | method = POST | ||
| overview = To cherry-pick a commit send a POST request to the git commit location. | | overview = To cherry-pick a commit send a POST request to the git commit location. | ||
− | | reqhead = /gitapi/commit/HEAD/file/ | + | | reqhead = /gitapi/commit/HEAD/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
| resphead = 200 OK | | resphead = 200 OK | ||
Line 489: | Line 503: | ||
| method = PUT | | method = PUT | ||
| overview = To tag a commit send a PUT request to the git commit location. | | overview = To tag a commit send a PUT request to the git commit location. | ||
− | | reqhead = / | + | | reqhead = /gitapi/commit/(revision)/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
{ | { | ||
"Name" : "{tag name}" | "Name" : "{tag name}" | ||
+ | "Annotated" : "{true or false}" | ||
+ | "Message" : "{annotated tag message}" | ||
} | } | ||
| resphead = 200 OK | | resphead = 200 OK | ||
Line 501: | Line 517: | ||
"AuthorName": "(author)", | "AuthorName": "(author)", | ||
"Children": ["(tag name)"], | "Children": ["(tag name)"], | ||
− | "ContentLocation": "http://localhost:8080/git/commit/(revision)/file/ | + | "ContentLocation": "http://localhost:8080/git/commit/(revision)/file/user-OrionContent/repo/?parts=body", |
− | "DiffLocation": "http://localhost:8080/git/diff/(revision)/file/ | + | "DiffLocation": "http://localhost:8080/git/diff/(revision)/file/user-OrionContent/repo/", |
− | "Location": "http://localhost:8080/git/commit/(revision)/file/ | + | "Location": "http://localhost:8080/git/commit/(revision)/file/user-OrionContent/repo/", |
"Message": "(commit message)", | "Message": "(commit message)", | ||
"Name": "(commit name)", | "Name": "(commit name)", | ||
Line 516: | Line 532: | ||
| method = DELETE | | method = DELETE | ||
| overview = To deleta a tag a DELETE request to the git tag location. | | overview = To deleta a tag a DELETE request to the git tag location. | ||
− | | reqhead = /gitapi/tag/tag1/file/ | + | | reqhead = /gitapi/tag/tag1/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
| resphead = 200 OK | | resphead = 200 OK | ||
Line 528: | Line 544: | ||
| method = GET | | method = GET | ||
| overview = To retrieve changes between working tree and index. Send a GET request to the git diff location. | | overview = To retrieve changes between working tree and index. Send a GET request to the git diff location. | ||
− | | reqhead = / | + | | reqhead = /gitapi/diff/Default/file/{:workspace_id}/{:repo_dir}/ |
Orion-Version: 1.0 | Orion-Version: 1.0 | ||
| resphead = HTTP/1.1 200 OK | | resphead = HTTP/1.1 200 OK | ||
Line 536: | Line 552: | ||
Content-Type: application/json | Content-Type: application/json | ||
| respbody = | | respbody = | ||
− | {"Base":"http://localhost:8080/git/index/file/ | + | { |
− | "Location":"http://localhost:8080/git/diff/Default/file/ | + | "Base":"http://localhost:8080/git/index/file/repo/a.txt", |
− | "New":"http://localhost:8080/file/ | + | "Location":"http://localhost:8080/git/diff/Default/file/repo/a.txt", |
− | "Old":"http://localhost:8080/git/index/file/ | + | "New":"http://localhost:8080/file/repo/a.txt", |
+ | "Old":"http://localhost:8080/git/index/file/repo/a.txt", | ||
"Type":"Diff" | "Type":"Diff" | ||
} | } | ||
Line 564: | Line 581: | ||
| method = GET | | method = GET | ||
| overview = To retrieve changes between index and HEAD. Send a GET request to the git diff location. | | overview = To retrieve changes between index and HEAD. Send a GET request to the git diff location. | ||
− | | reqhead = / | + | | reqhead = /gitapi/diff/Cached/file/{:workspace_id}/{:repo_dir}/ |
Orion-Version: 1.0 | Orion-Version: 1.0 | ||
| resphead = HTTP/1.1 200 OK | | resphead = HTTP/1.1 200 OK | ||
Line 572: | Line 589: | ||
Content-Type: application/json | Content-Type: application/json | ||
| respbody = | | respbody = | ||
− | {"Base":"http://localhost:8080/git/index/file/ | + | { |
− | "Diff":"http://localhost:8080/git/diff/Default/file/ | + | "Base":"http://localhost:8080/git/index/file/repo/a.txt", |
− | "New":"http://localhost:8080/file/ | + | "Diff":"http://localhost:8080/git/diff/Default/file/repo/a.txt", |
− | "Old":"http://localhost:8080/git/index/file/ | + | "New":"http://localhost:8080/file/repo/a.txt", |
+ | "Old":"http://localhost:8080/git/index/file/repo/a.txt", | ||
"Type":"Diff" | "Type":"Diff" | ||
} | } | ||
Line 600: | Line 618: | ||
| method = GET | | method = GET | ||
| overview = To retrieve changes between two commits. Send a GET request to the git diff location. | | overview = To retrieve changes between two commits. Send a GET request to the git diff location. | ||
− | | reqhead = / | + | | reqhead = /gitapi/diff/{:old revision}..{:new revision}/file/{:workspace_id}/{:repo_dir}/?parts={:diffs/uris}&pageSize={:page_size}&page={:page_number} |
Orion-Version: 1.0 | Orion-Version: 1.0 | ||
| resphead = HTTP/1.1 200 OK | | resphead = HTTP/1.1 200 OK | ||
Line 608: | Line 626: | ||
Content-Type: application/json | Content-Type: application/json | ||
| respbody = | | respbody = | ||
− | {"Base":"http://localhost:8080/git/index/file/ | + | { |
− | "Location":"http://localhost:8080/git/diff/Default/file/ | + | "Base":"http://localhost:8080/git/index/file/repo/a.txt", |
− | "New":"http://localhost:8080/file/ | + | "Location":"http://localhost:8080/git/diff/Default/file/repo/a.txt", |
− | "Old":"http://localhost:8080/git/index/file/ | + | "New":"http://localhost:8080/file/repo/a.txt", |
+ | "Old":"http://localhost:8080/git/index/file/repo/a.txt", | ||
"Type":"Diff" | "Type":"Diff" | ||
} | } | ||
Line 628: | Line 647: | ||
+Elod | +Elod | ||
+Something | +Something | ||
− | | explain = | + | | explain = If query parameter "parts=diffs" then "pageSize" and "page" must also be specified. |
}} | }} | ||
Line 636: | Line 655: | ||
| method = POST | | method = POST | ||
| overview = To get a diff location for two commits. Send a POST request to the git diff location for old commit. | | overview = To get a diff location for two commits. Send a POST request to the git diff location for old commit. | ||
− | | reqhead = / | + | | reqhead = /gitapi/diff/{:old revision}/file/{:workspace_id}/{:repo_dir}/{:file_path} |
| reqbody = { | | reqbody = { | ||
"New" : "{new revision}" | "New" : "{new revision}" | ||
Line 643: | Line 662: | ||
Content-Type: text/plain | Content-Type: text/plain | ||
Content-Length: 22 | Content-Length: 22 | ||
− | Location: /git/diff/{old revision}..{new revision}/file/ | + | Location: /git/diff/{old revision}..{new revision}/file/repo/ |
| respbody = | | respbody = | ||
<nothing> | <nothing> | ||
Line 649: | Line 668: | ||
}} | }} | ||
− | === Getting | + | === Getting file content from index === |
{{Orion/ServerAPI | {{Orion/ServerAPI | ||
| method = GET | | method = GET | ||
| overview = To retrieve file content kept in index. Send a GET request to the git index location. | | overview = To retrieve file content kept in index. Send a GET request to the git index location. | ||
− | | reqhead = / | + | | reqhead = /gitapi/index/file/{:workspace_id}/{:repo_dir}/{:file_path} |
| resphead = 200 OK | | resphead = 200 OK | ||
Content-Type: text/plain | Content-Type: text/plain | ||
Line 663: | Line 682: | ||
}} | }} | ||
− | === | + | === Unstage all files in the index === |
{{Orion/ServerAPI | {{Orion/ServerAPI | ||
| method = POST | | method = POST | ||
− | | overview = To unstage all | + | | overview = To unstage all previously-staged files, reset index and/or working tree. Send a POST request to the git index location. |
− | | reqhead = / | + | | reqhead = /gitapi/index/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = { | | reqbody = { | ||
"Reset" : "MIXED" | "Reset" : "MIXED" | ||
Line 681: | Line 700: | ||
{{Orion/ServerAPI | {{Orion/ServerAPI | ||
| method = POST | | method = POST | ||
− | | overview = To unstage a group | + | | overview = To unstage a group of files. Send a POST request to the git index location. |
− | | reqhead = / | + | | reqhead = /gitapi/index/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = { | | reqbody = { | ||
"Path" : ["folder/file.txt", "file1.txt" ] | "Path" : ["folder/file.txt", "file1.txt" ] | ||
Line 696: | Line 715: | ||
| method = POST | | method = POST | ||
| overview = To unstage an individual file. Send a POST request to the git index location. | | overview = To unstage an individual file. Send a POST request to the git index location. | ||
− | | reqhead = / | + | | reqhead = /gitapi/index/file/{:workspace_id}/{:repo_dir}/file.txt |
| resphead = 200 OK | | resphead = 200 OK | ||
| respbody = | | respbody = | ||
Line 707: | Line 726: | ||
| method = PUT | | method = PUT | ||
| overview = To stage a file, add it to the index. Send a PUT request to the git index location. | | overview = To stage a file, add it to the index. Send a PUT request to the git index location. | ||
− | | reqhead = /gitapi/index/file/ | + | | reqhead = /gitapi/index/file/{:workspace_id}/{:repo_dir}/{:file_path} |
| resphead = 200 OK | | resphead = 200 OK | ||
| respbody = | | respbody = | ||
Line 718: | Line 737: | ||
| method = PUT | | method = PUT | ||
| overview = To stage multiple files, add them to the index. Send a PUT request to the git index location. | | overview = To stage multiple files, add them to the index. Send a PUT request to the git index location. | ||
− | | reqhead = /gitapi/index/file/ | + | | reqhead = /gitapi/index/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
{ | { | ||
Line 731: | Line 750: | ||
{{Orion/ServerAPI | {{Orion/ServerAPI | ||
− | | method = | + | | method = GET |
| overview = To get the list of remotes send a GET request to the git remote location. | | overview = To get the list of remotes send a GET request to the git remote location. | ||
− | | reqhead = / | + | | reqhead = /gitapi/remote/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
| resphead = 200 OK | | resphead = 200 OK | ||
| respbody = | | respbody = | ||
− | + | { | |
− | + | "Children": [ | |
− | + | { | |
− | + | "CloneLocation": "/gitapi/clone/file/user-OrionContent/repo/orion.client/", | |
+ | "GitUrl": "https://github.com/user/orion.client.git", | ||
+ | "IsGerrit": false, | ||
+ | "Location": "/gitapi/remote/origin/file/user-OrionContent/repo/orion.client/", | ||
+ | "Name": "origin", | ||
+ | "Type": "Remote" | ||
+ | }, | ||
+ | { | ||
+ | "CloneLocation": "/gitapi/clone/file/user-OrionContent/repo/orion.client/", | ||
+ | "GitUrl": "http://git.eclipse.org/gitroot/orion/org.eclipse.orion.client.git", | ||
+ | "IsGerrit": false, | ||
+ | "Location": "/gitapi/remote/upstream/file/user-OrionContent/repo/orion.client/", | ||
+ | "Name": "upstream", | ||
+ | "Type": "Remote" | ||
+ | } | ||
+ | ], | ||
+ | "Type": "Remote" | ||
+ | } | ||
| explain = TBD | | explain = TBD | ||
}} | }} | ||
− | === Getting the list of remote's branches === | + | === Getting the list of a remote's branches === |
{{Orion/ServerAPI | {{Orion/ServerAPI | ||
| method = GET | | method = GET | ||
− | | overview = To get the list of remote's branches send a GET request to the git remote location. | + | | overview = To get the list of a remote's branches send a GET request to the git remote location. |
− | | reqhead = / | + | | reqhead = /gitapi/remote/{:remote}/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
| resphead = 200 OK | | resphead = 200 OK | ||
Line 755: | Line 791: | ||
{ | { | ||
"Children": [{ | "Children": [{ | ||
− | "CommitLocation": "http://localhost:8080/git/commit/bbbcc34fe10c2d731e7f97618f4f469c2f763a31/file/ | + | "CommitLocation": "http://localhost:8080/git/commit/bbbcc34fe10c2d731e7f97618f4f469c2f763a31/file/repo/", |
"Id": "bbbcc34fe10c2d731e7f97618f4f469c2f763a31", | "Id": "bbbcc34fe10c2d731e7f97618f4f469c2f763a31", | ||
− | "Location": "http://localhost:8080/git/remote/origin/master/file/ | + | "Location": "http://localhost:8080/git/remote/origin/master/file/repo/", |
"Name": "refs/remotes/origin/master" | "Name": "refs/remotes/origin/master" | ||
}], | }], | ||
− | "Location": "http://localhost:8080/git/remote/origin/file/ | + | "Location": "http://localhost:8080/git/remote/origin/file/repo/", |
"Name": "origin" | "Name": "origin" | ||
} | } | ||
Line 771: | Line 807: | ||
| method = GET | | method = GET | ||
| overview = To get the remote branch details send a GET request to the git remote location. | | overview = To get the remote branch details send a GET request to the git remote location. | ||
− | | reqhead = / | + | | reqhead = /gitapi/remote/{:remote}/{:branch}/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
| resphead = 200 OK | | resphead = 200 OK | ||
| respbody = | | respbody = | ||
{ | { | ||
− | "CommitLocation": "http://localhost:8080/git/commit/bbbcc34fe10c2d731e7f97618f4f469c2f763a31/file/ | + | "CommitLocation": "http://localhost:8080/git/commit/bbbcc34fe10c2d731e7f97618f4f469c2f763a31/file/repo/", |
− | "HeadLocation": "http://localhost:8080/git/commit/HEAD/file/ | + | "HeadLocation": "http://localhost:8080/git/commit/HEAD/file/repo/", |
"Id": "bbbcc34fe10c2d731e7f97618f4f469c2f763a31", | "Id": "bbbcc34fe10c2d731e7f97618f4f469c2f763a31", | ||
− | "Location": "http://localhost:8080/git/remote/origin/master/file/ | + | "Location": "http://localhost:8080/git/remote/origin/master/file/repo/" |
} | } | ||
| explain = TBD | | explain = TBD | ||
Line 789: | Line 825: | ||
| method = POST | | method = POST | ||
| overview = To add a new remote send a POST request to the git remote location. | | overview = To add a new remote send a POST request to the git remote location. | ||
− | | reqhead = / | + | | reqhead = /gitapi/remote/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
{ | { | ||
Line 796: | Line 832: | ||
"FetchRefSpec" : "{fetch refspec - optional}", | "FetchRefSpec" : "{fetch refspec - optional}", | ||
"PushURI" : "{remote push URI - optional}", | "PushURI" : "{remote push URI - optional}", | ||
− | " | + | "PushRefSpec" : "{push refspec - optional}" |
} | } | ||
| resphead = 201 CREATED | | resphead = 201 CREATED | ||
− | Location: http://localhost:8080/git/remote/newremote/file/ | + | Location: http://localhost:8080/git/remote/newremote/file/repo/ |
Content-Type: application/json | Content-Type: application/json | ||
| respbody = | | respbody = | ||
{ | { | ||
− | "Location": "http://localhost:8080/git/remote/newremote/file/ | + | "Location": "http://localhost:8080/git/remote/newremote/file/repo/" |
} | } | ||
} | } | ||
Line 814: | Line 850: | ||
| method = POST | | method = POST | ||
| overview = To fetch changes from a remote send a POST request to the git branch location. | | overview = To fetch changes from a remote send a POST request to the git branch location. | ||
− | | reqhead = / | + | | reqhead = /gitapi/remote/{:remote}/{:branch}/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
| resphead = 201 CREATED | | resphead = 201 CREATED | ||
Line 823: | Line 859: | ||
"GitSshUsername" : "{git ssh username}", | "GitSshUsername" : "{git ssh username}", | ||
"GitSshPassword" : "{git ssh password}", | "GitSshPassword" : "{git ssh password}", | ||
− | |||
"GitSshPrivateKey" : "{git ssh private key}", | "GitSshPrivateKey" : "{git ssh private key}", | ||
"GitSshPassphrase" : "{git ssh passphrase}" | "GitSshPassphrase" : "{git ssh passphrase}" | ||
Line 843: | Line 878: | ||
| method = POST | | method = POST | ||
| overview = To push changes from a remote send a POST request to the git branch location. | | overview = To push changes from a remote send a POST request to the git branch location. | ||
− | | reqhead = / | + | | reqhead = /gitapi/remote/{:remote}/{:branch}/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
| resphead = 201 CREATED | | resphead = 201 CREATED | ||
Line 849: | Line 884: | ||
{ | { | ||
"PushSrcRef" : "HEAD", | "PushSrcRef" : "HEAD", | ||
− | "PushTags" : "true" | + | "PushTags" : "true", |
+ | "Force" : "false", | ||
"GitSshKnownHost" : "{git ssh known host}", | "GitSshKnownHost" : "{git ssh known host}", | ||
"GitSshUsername" : "{git ssh username}", | "GitSshUsername" : "{git ssh username}", | ||
"GitSshPassword" : "{git ssh password}", | "GitSshPassword" : "{git ssh password}", | ||
− | |||
"GitSshPrivateKey" : "{git ssh private key}", | "GitSshPrivateKey" : "{git ssh private key}", | ||
"GitSshPassphrase" : "{git ssh passphrase}" | "GitSshPassphrase" : "{git ssh passphrase}" | ||
Line 873: | Line 908: | ||
| method = DELETE | | method = DELETE | ||
| overview = To delete the remote send a DELETE request to the git remote location. | | overview = To delete the remote send a DELETE request to the git remote location. | ||
− | | reqhead = / | + | | reqhead = /gitapi/remote/{:remote}/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
| resphead = 200 OK | | resphead = 200 OK | ||
Line 885: | Line 920: | ||
| method = GET | | method = GET | ||
| overview = To retrieve the working tree status of a project, send a GET request to the git status location. | | overview = To retrieve the working tree status of a project, send a GET request to the git status location. | ||
− | | reqhead = /gitapi/status/file/ | + | | reqhead = /gitapi/status/file/{:workspace_id}/{:repo_dir}/ |
| resphead = 200 OK | | resphead = 200 OK | ||
Content-Type: application/json; charset=UTF-8 | Content-Type: application/json; charset=UTF-8 | ||
Line 893: | Line 928: | ||
"Added": [], | "Added": [], | ||
"Changed": [], | "Changed": [], | ||
− | "CommitLocation": "http://localhost:8080/git/commit/HEAD/file/ | + | "CommitLocation": "http://localhost:8080/git/commit/HEAD/file/repo/", |
"Conflicting": [], | "Conflicting": [], | ||
− | "IndexLocation": "http://localhost:8080/git/index/file/ | + | "IndexLocation": "http://localhost:8080/git/index/file/repo/", |
"Missing": [], | "Missing": [], | ||
"Modified": [{ | "Modified": [{ | ||
"Git": { | "Git": { | ||
− | "CommitLocation": "http://localhost:8080/git/commit/HEAD/file/ | + | "CommitLocation": "http://localhost:8080/git/commit/HEAD/file/repo/a.txt", |
− | "DiffLocation": "http://localhost:8080/git/diff/Default/file/ | + | "DiffLocation": "http://localhost:8080/git/diff/Default/file/repo/a.txt", |
− | "IndexLocation": "http://localhost:8080/git/index/file/ | + | "IndexLocation": "http://localhost:8080/git/index/file/repo/a.txt" |
}, | }, | ||
− | "Location": "http://localhost:8080/file/ | + | "Location": "http://localhost:8080/file/repo/a.txt", |
"Name": "a.txt", | "Name": "a.txt", | ||
"Path": "a.txt" | "Path": "a.txt" | ||
Line 916: | Line 951: | ||
{{Orion/ServerAPI | {{Orion/ServerAPI | ||
− | | method = | + | | method = PUT |
− | | overview = To tag a commit send a | + | | overview = To tag a commit send a PUT request to the git tag location. |
− | | reqhead = /gitapi/ | + | | reqhead = /gitapi/commit/{:refId}/file/{:workspace_id}/{:repo_dir} |
| reqbody = | | reqbody = | ||
{ | { | ||
− | "Name" : " | + | "Name" : "{tag name}", |
− | " | + | "Annotated" : boolean, |
+ | "Message" : "{annotated message}", | ||
} | } | ||
| resphead = 201 CREATED | | resphead = 201 CREATED | ||
Line 936: | Line 972: | ||
| method = GET | | method = GET | ||
| overview = To get the list of tags send a GET request to the git tag location. | | overview = To get the list of tags send a GET request to the git tag location. | ||
− | | reqhead = /gitapi/tag/file/ | + | | reqhead = /gitapi/tag/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
| resphead = 200 OK | | resphead = 200 OK | ||
Line 963: | Line 999: | ||
| method = GET | | method = GET | ||
| overview = To get the list of branches send a GET request to the git tag location. | | overview = To get the list of branches send a GET request to the git tag location. | ||
− | | reqhead = /gitapi/branch/file/ | + | | reqhead = /gitapi/branch/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
| resphead = 200 OK | | resphead = 200 OK | ||
Line 970: | Line 1,006: | ||
"Children": [ | "Children": [ | ||
{ | { | ||
− | "CloneLocation": "http://localhost:8080/gitapi/clone/file/ | + | "CloneLocation": "http://localhost:8080/gitapi/clone/file/repo/", |
− | "CommitLocation": "http://localhost:8080/gitapi/commit/master/file/ | + | "CommitLocation": "http://localhost:8080/gitapi/commit/master/file/repo/", |
"Current": true, | "Current": true, | ||
− | "HeadLocation": "http://localhost:8080/gitapi/commit/HEAD/file/ | + | "HeadLocation": "http://localhost:8080/gitapi/commit/HEAD/file/repo/", |
− | "Location": "http://localhost:8080/gitapi/branch/master/file/ | + | "Location": "http://localhost:8080/gitapi/branch/master/file/repo/", |
"Name": "master", | "Name": "master", | ||
− | "RemoteLocation": "http://localhost:8080/gitapi/remote/origin/master/file/ | + | "RemoteLocation": "http://localhost:8080/gitapi/remote/origin/master/file/repo/", |
"Type": "Branch" | "Type": "Branch" | ||
}, | }, | ||
{ | { | ||
− | "CloneLocation": "http://localhost:8080/gitapi/clone/file/ | + | "CloneLocation": "http://localhost:8080/gitapi/clone/file/repo/", |
− | "CommitLocation": "http://localhost:8080/gitapi/commit/dev/file/ | + | "CommitLocation": "http://localhost:8080/gitapi/commit/dev/file/repo/", |
"Current": false, | "Current": false, | ||
− | "HeadLocation": "http://localhost:8080/gitapi/commit/HEAD/file/ | + | "HeadLocation": "http://localhost:8080/gitapi/commit/HEAD/file/repo/", |
− | "Location": "http://localhost:8080/gitapi/branch/dev/file/ | + | "Location": "http://localhost:8080/gitapi/branch/dev/file/repo/", |
"Name": "dev", | "Name": "dev", | ||
− | "RemoteLocation": "http://localhost:8080/gitapi/remote/origin/dev/file/ | + | "RemoteLocation": "http://localhost:8080/gitapi/remote/origin/dev/file/repo/", |
"Type": "Branch" | "Type": "Branch" | ||
} | } | ||
Line 998: | Line 1,034: | ||
| method = GET | | method = GET | ||
| overview = To get more info about a branch send a GET request to its git branch location. | | overview = To get more info about a branch send a GET request to its git branch location. | ||
− | | reqhead = /gitapi/branch/master/file/ | + | | reqhead = /gitapi/branch/master/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
| resphead = 200 OK | | resphead = 200 OK | ||
| respbody = | | respbody = | ||
{ | { | ||
− | "CloneLocation": "http://localhost:8080/gitapi/clone/file/ | + | "CloneLocation": "http://localhost:8080/gitapi/clone/file/repo/", |
− | "CommitLocation": "http://localhost:8080/gitapi/commit/master/file/ | + | "CommitLocation": "http://localhost:8080/gitapi/commit/master/file/repo/", |
"Current": true, | "Current": true, | ||
− | "HeadLocation": "http://localhost:8080/gitapi/commit/HEAD/file/ | + | "DiffLocation": "http://localhost:8080/gitapi/diff/master/file/repo/", |
− | "Location": "http://localhost:8080/gitapi/branch/master/file/ | + | "FullName": "refs/heads/master", |
+ | "HeadLocation": "http://localhost:8080/gitapi/commit/HEAD/file/repo/", | ||
+ | "LocalTimeStamp": 1234567890000, | ||
+ | "Location": "http://localhost:8080/gitapi/branch/master/file/repo/", | ||
"Name": "master", | "Name": "master", | ||
− | "RemoteLocation": "http://localhost:8080/gitapi/remote/origin/master/file/ | + | "RemoteLocation": ["http://localhost:8080/gitapi/remote/origin/master/file/repo/"], |
+ | "TreeLocation": "http://localhost:8080/gitapi/tree/file/repo/master", | ||
"Type": "Branch" | "Type": "Branch" | ||
} | } | ||
Line 1,020: | Line 1,060: | ||
| method = POST | | method = POST | ||
| overview = To create a local send a POST request to the git BranchLocation. The data must be JSON. | | overview = To create a local send a POST request to the git BranchLocation. The data must be JSON. | ||
− | | reqhead = /gitapi/branch/file/ | + | | reqhead = /gitapi/branch/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
| resphead = 201 CREATED | | resphead = 201 CREATED | ||
Line 1,026: | Line 1,066: | ||
{ | { | ||
"Name" : "dev", | "Name" : "dev", | ||
− | "Branch" : "{starting point}" | + | "Branch" : "{starting point}" (if omitted the current HEAD will be used) |
} | } | ||
| respbody = | | respbody = | ||
{ | { | ||
− | "CloneLocation": "http://localhost:8080/gitapi/clone/file/ | + | "CloneLocation": "http://localhost:8080/gitapi/clone/file/repo/", |
− | "CommitLocation": "http://localhost:8080/gitapi/commit/dev/file/ | + | "CommitLocation": "http://localhost:8080/gitapi/commit/dev/file/repo/", |
"Current": false, | "Current": false, | ||
− | "HeadLocation": "http://localhost:8080/gitapi/commit/HEAD/file/ | + | "HeadLocation": "http://localhost:8080/gitapi/commit/HEAD/file/repo/", |
− | "Location": "http://localhost:8080/gitapi/branch/dev/file/ | + | "Location": "http://localhost:8080/gitapi/branch/dev/file/repo/", |
"Name": "dev", | "Name": "dev", | ||
− | "RemoteLocation": "http://localhost:8080/gitapi/remote/origin/dev/file/ | + | "RemoteLocation": "http://localhost:8080/gitapi/remote/origin/dev/file/repo/", |
"Type": "Branch" | "Type": "Branch" | ||
} | } | ||
Line 1,047: | Line 1,087: | ||
| method = DELETE | | method = DELETE | ||
| overview = To remove a local branch send a DELETE request to its git branch location. | | overview = To remove a local branch send a DELETE request to its git branch location. | ||
− | | reqhead = /gitapi/branch/master/file/ | + | | reqhead = /gitapi/branch/master/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
| resphead = 200 OK | | resphead = 200 OK | ||
Line 1,059: | Line 1,099: | ||
| method = PUT | | method = PUT | ||
| overview = To checkout a branch send a PUT request to the git clone Location. The data must be JSON. | | overview = To checkout a branch send a PUT request to the git clone Location. The data must be JSON. | ||
− | | reqhead = /gitapi/clone/file/ | + | | reqhead = /gitapi/clone/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
{ | { | ||
Line 1,074: | Line 1,114: | ||
| method = PUT | | method = PUT | ||
| overview = To checkout a tag send a PUT request to the git clone location. A new branch will be created for the requested tag. | | overview = To checkout a tag send a PUT request to the git clone location. A new branch will be created for the requested tag. | ||
− | | reqhead = /gitapi/clone/file/ | + | | reqhead = /gitapi/clone/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
{ | { | ||
Line 1,090: | Line 1,130: | ||
| method = PUT | | method = PUT | ||
| overview = To checkout a file send a PUT request to the git clone location. | | overview = To checkout a file send a PUT request to the git clone location. | ||
− | | reqhead = /gitapi/clone/file/ | + | | reqhead = /gitapi/clone/file/{:workspace_id}/{:repo_dir}/ |
| reqbody = | | reqbody = | ||
{ | { | ||
− | "Path" : "folder/file.txt" | + | "Path" : ["folder/file.txt"] |
} | } | ||
| resphead = 200 OK | | resphead = 200 OK | ||
Line 1,104: | Line 1,144: | ||
{{Orion/ServerAPI | {{Orion/ServerAPI | ||
| method = GET | | method = GET | ||
− | | overview = To get list of commits (log) send a GET request to | + | | overview = To get list of commits (log) send a GET request to the HeadLocation. |
− | | reqhead = /gitapi/commit/HEAD/file/ | + | | reqhead = /gitapi/commit/HEAD/file/{:workspace_id}/{:repo_dir}/?parts=log |
| reqbody = | | reqbody = | ||
| resphead = 200 OK | | resphead = 200 OK | ||
Line 1,117: | Line 1,157: | ||
"CommitterEmail": "Tomasz.Zarna@pl.ibm.com", | "CommitterEmail": "Tomasz.Zarna@pl.ibm.com", | ||
"CommitterName": "Tomasz Zarna", | "CommitterName": "Tomasz Zarna", | ||
− | "ContentLocation": "http://localhost:8080/gitapi/commit/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/ | + | "ContentLocation": "http://localhost:8080/gitapi/commit/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/repo/?parts=body", |
− | "DiffLocation": "http://localhost:8080/gitapi/diff/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/ | + | "DiffLocation": "http://localhost:8080/gitapi/diff/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/repo/", |
"Diffs": [{ | "Diffs": [{ | ||
"ChangeType": "MODIFY", | "ChangeType": "MODIFY", | ||
− | "DiffLocation": "http://localhost:8080/gitapi/diff/1fe0d121457ec1fc61d86e497576972443cdb14a..91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/ | + | "DiffLocation": "http://localhost:8080/gitapi/diff/1fe0d121457ec1fc61d86e497576972443cdb14a..91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/repo/test.txt", |
"NewPath": "test.txt", | "NewPath": "test.txt", | ||
"OldPath": "test.txt", | "OldPath": "test.txt", | ||
"Type": "Diff" | "Type": "Diff" | ||
}], | }], | ||
− | "Location": "http://localhost:8080/gitapi/commit/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/ | + | "Location": "http://localhost:8080/gitapi/commit/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/repo/", |
"Message": "fixing bug 349827", | "Message": "fixing bug 349827", | ||
"Name": "91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9", | "Name": "91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9", | ||
Line 1,135: | Line 1,175: | ||
"RepositoryPath": "", | "RepositoryPath": "", | ||
"toRef": { | "toRef": { | ||
− | "CloneLocation": "http://localhost:8080/gitapi/clone/file/ | + | "CloneLocation": "http://localhost:8080/gitapi/clone/file/repo/", |
− | "CommitLocation": "http://localhost:8080/gitapi/commit/master/file/ | + | "CommitLocation": "http://localhost:8080/gitapi/commit/master/file/repo/", |
"Current": true, | "Current": true, | ||
− | "HeadLocation": "http://localhost:8080/gitapi/commit/HEAD/file/ | + | "HeadLocation": "http://localhost:8080/gitapi/commit/HEAD/file/repo/", |
− | "Location": "http://localhost:8080/gitapi/branch/master/file/ | + | "Location": "http://localhost:8080/gitapi/branch/master/file/repo/", |
"Name": "master", | "Name": "master", | ||
"Type": "Branch" | "Type": "Branch" | ||
} | } | ||
} | } | ||
− | | explain = The response contains list of commits (see response for [[#Committing all files in index]]) and details about refs used in the log when available. | + | | explain = The response contains list of commits (see response for [[#Committing all files in index]]) and details about refs used in the log when available. |
+ | There is also an alternative API where (I guess ''?parts=log'' is replaced by) ''?page=page_no&pageSize=page_size''. In the response you'll get NextLocation | ||
+ | and PreviousLocation that will direct you to the next and previous page. | ||
+ | }} | ||
+ | |||
+ | === Listing commits revision or named commits === | ||
+ | |||
+ | {{Orion/ServerAPI | ||
+ | | method = GET | ||
+ | | overview = To get list of commits (log) using a [http://schacon.github.com/git/gitrevisions.html revision]. If ''revision'' is "master..myBranch", the response will be the commits on ''myBranch'' since it was branched from ''master''. If ''revision'' is "master~4..master", the response will be the 4 most recent commits on ''master''; if there are less than 4, the result will be status 400 error. | ||
+ | | reqhead = /gitapi/commit/master~4..master/file/{:workspace_id}/{:repo_dir} | ||
+ | | reqbody = | ||
+ | | resphead = 200 OK | ||
+ | | respbody = | ||
+ | { | ||
+ | "Children": [ | ||
+ | { | ||
+ | "AuthorEmail": "Tomasz.Zarna@pl.ibm.com", | ||
+ | "AuthorName": "Tomasz Zarna", | ||
+ | "Children": [], | ||
+ | "CommitterEmail": "Tomasz.Zarna@pl.ibm.com", | ||
+ | "CommitterName": "Tomasz Zarna", | ||
+ | "ContentLocation": "http://localhost:8080/gitapi/commit/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/repo/?parts=body", | ||
+ | "DiffLocation": "http://localhost:8080/gitapi/diff/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/repo/", | ||
+ | "Diffs": [{ | ||
+ | "ChangeType": "MODIFY", | ||
+ | "DiffLocation": "http://localhost:8080/gitapi/diff/1fe0d121457ec1fc61d86e497576972443cdb14a..91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/repo/test.txt", | ||
+ | "NewPath": "test.txt", | ||
+ | "OldPath": "test.txt", | ||
+ | "Type": "Diff" | ||
+ | }], | ||
+ | "Location": "http://localhost:8080/gitapi/commit/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/repo/", | ||
+ | "Message": "fixing bug 349827", | ||
+ | "Name": "91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9", | ||
+ | "Time": 1308918640000, | ||
+ | "Type": "Commit" | ||
+ | } | ||
+ | ], | ||
+ | "RepositoryPath": "", | ||
+ | "toRef": { | ||
+ | "CloneLocation": "http://localhost:8080/gitapi/clone/file/repo/", | ||
+ | "CommitLocation": "http://localhost:8080/gitapi/commit/master/file/repo/", | ||
+ | "Current": true, | ||
+ | "HeadLocation": "http://localhost:8080/gitapi/commit/HEAD/file/repo/", | ||
+ | "Location": "http://localhost:8080/gitapi/branch/master/file/repo/", | ||
+ | "Name": "master", | ||
+ | "Type": "Branch" | ||
+ | } | ||
+ | } | ||
+ | | explain = The response contains an array of commits on the Children property. | ||
}} | }} | ||
Line 1,152: | Line 1,241: | ||
| method = GET | | method = GET | ||
| overview = To get details of a commit send a GET request to git commit location. | | overview = To get details of a commit send a GET request to git commit location. | ||
− | | reqhead = /gitapi/commit/c47c36518cd8aaf01b84afa55cf9a75badc882d9/file/ | + | | reqhead = /gitapi/commit/c47c36518cd8aaf01b84afa55cf9a75badc882d9/file/{:workspace_id}/{:repo_dir}/{:file_path} |
| reqbody = | | reqbody = | ||
| resphead = 200 OK | | resphead = 200 OK | ||
Line 1,163: | Line 1,252: | ||
"CommitterEmail": "Tomasz.Zarna@pl.ibm.com", | "CommitterEmail": "Tomasz.Zarna@pl.ibm.com", | ||
"CommitterName": "Tomasz Zarna", | "CommitterName": "Tomasz Zarna", | ||
− | "ContentLocation": "http://localhost:8080/gitapi/commit/c47c36518cd8aaf01b84afa55cf9a75badc882d9/file/ | + | "ContentLocation": "http://localhost:8080/gitapi/commit/c47c36518cd8aaf01b84afa55cf9a75badc882d9/file/filepath/?parts=body", |
− | "DiffLocation": "http://localhost:8080/gitapi/diff/c47c36518cd8aaf01b84afa55cf9a75badc882d9/file/ | + | "DiffLocation": "http://localhost:8080/gitapi/diff/c47c36518cd8aaf01b84afa55cf9a75badc882d9/file/filepath/", |
− | "Location": "http://localhost:8080/gitapi/commit/c47c36518cd8aaf01b84afa55cf9a75badc882d9/file/ | + | "Location": "http://localhost:8080/gitapi/commit/c47c36518cd8aaf01b84afa55cf9a75badc882d9/file/filepath/", |
"Message": "initial commit\n", | "Message": "initial commit\n", | ||
"Name": "c47c36518cd8aaf01b84afa55cf9a75badc882d9", | "Name": "c47c36518cd8aaf01b84afa55cf9a75badc882d9", | ||
Line 1,175: | Line 1,264: | ||
| explain = The response contains details for the selected commit. | | explain = The response contains details for the selected commit. | ||
}} | }} | ||
− | |||
=== Getting file content in a commit === | === Getting file content in a commit === | ||
Line 1,182: | Line 1,270: | ||
| method = GET | | method = GET | ||
| overview = To retrieve file content kept for a specific commit. Send a GET request to the git commit location. | | overview = To retrieve file content kept for a specific commit. Send a GET request to the git commit location. | ||
− | | reqhead = /gitapi/commit/c47c36518cd8aaf01b84afa55cf9a75badc882d9/file/ | + | | reqhead = /gitapi/commit/c47c36518cd8aaf01b84afa55cf9a75badc882d9/file/{:workspace_id}/{:repo_dir}/{:file_path}?parts=body |
| reqbody = | | reqbody = | ||
| resphead = 200 OK | | resphead = 200 OK | ||
Line 1,188: | Line 1,276: | ||
I'm content of file.txt | I'm content of file.txt | ||
| explain = The response contains content of the selected file in the given commit. | | explain = The response contains content of the selected file in the given commit. | ||
+ | }} | ||
+ | |||
+ | === Getting blame result from HEAD === | ||
+ | |||
+ | {{Orion/ServerAPI | ||
+ | | method = GET | ||
+ | | overview = Retrieve blame information for the specified file from HEAD. | ||
+ | | reqhead = /gitapi/blame/HEAD/file/{:workspace_id}/{:repo_dir}/{:file_path} | ||
+ | | reqbody = | ||
+ | | resphead = 200 OK | ||
+ | | respbody = | ||
+ | { | ||
+ | "Children": [ | ||
+ | { | ||
+ | "AuthorEmail": "author@email.com ", | ||
+ | "AuthorImage": "http://www.gravatar.com/avatar/677bc1ca5ef557ab8f9c94038c0312b7?d=mm", | ||
+ | "AuthorName": "Author Name", | ||
+ | "CommitLocation": "/gitapi/commit/4065d87b7a839f41d9be40ca11b7ad2f78784bcc/file/location/", | ||
+ | "Message": "commit message", | ||
+ | "Name": "4065d87b7a839f41d9be40ca11b7ad2f78784bcc", | ||
+ | "Time": 1367897569, | ||
+ | "Children": [ | ||
+ | { | ||
+ | "Start": "1", | ||
+ | "End": "4" | ||
+ | }, | ||
+ | { | ||
+ | "Start": "7", | ||
+ | "End": "8" | ||
+ | }, | ||
+ | ... | ||
+ | ] | ||
+ | }, | ||
+ | ... | ||
+ | ], | ||
+ | "CloneLocation": "/gitapi/clone/file/location/", | ||
+ | "Location": "/gitapi/blame/HEAD/file/Name/location/file.js", | ||
+ | "Type": "Blame" | ||
+ | } | ||
+ | | explain = The response contains all of the information needed to generate blame for the current file. Each commit that appears in the file's blame information resides in the responses' children. For each commit the author's name, email and Gravatar image link are included, along with the commit's location, message, name and time. Each commit also contains an array of line ranges which are blamed to this commit. | ||
+ | }} | ||
+ | |||
+ | === Getting blame result from commit === | ||
+ | |||
+ | {{Orion/ServerAPI | ||
+ | | method = GET | ||
+ | | overview = Retrieve blame information for the specified file for a commit. | ||
+ | | reqhead = /gitapi/blame/{:sha}/file/{:workspace_id}/{:repo_dir}/{:file_path} | ||
+ | | reqbody = | ||
+ | | resphead = 200 OK | ||
+ | | respbody = | ||
+ | { | ||
+ | "Children": [ | ||
+ | { | ||
+ | "AuthorEmail": "author@email.com ", | ||
+ | "AuthorImage": "http://www.gravatar.com/avatar/677bc1ca5ef557ab8f9c94038c0312b7?d=mm", | ||
+ | "AuthorName": "Author Name", | ||
+ | "CommitLocation": "/gitapi/commit/af15c87b26c75263c005db59fb1513190b05c3f1/file/location/", | ||
+ | "Message": "commit message", | ||
+ | "Name": "af15c87b26c75263c005db59fb1513190b05c3f1", | ||
+ | "Time": 1367894569, | ||
+ | "Children": [ | ||
+ | { | ||
+ | "Start": "1", | ||
+ | "End": "3" | ||
+ | }, | ||
+ | { | ||
+ | "Start": "7", | ||
+ | "End": "8" | ||
+ | }, | ||
+ | ... | ||
+ | ] | ||
+ | }, | ||
+ | ... | ||
+ | ], | ||
+ | "CloneLocation": "/gitapi/clone/file/location/", | ||
+ | "Location": "/gitapi/blame/HEAD/file/Name/location/file.js", | ||
+ | "Type": "Blame" | ||
+ | } | ||
+ | |||
+ | | explain = The response contains the blame information for a file for a certain commit. See [[#Getting blame result from HEAD]] | ||
}} | }} | ||
Latest revision as of 12:10, 20 December 2017
The Git API is a web server API for browsing and manipulating Git repositories.
Contents
- 1 Resource/HTTP method matrix
- 2 Git commands
- 2.1 git add
- 2.2 git blame
- 2.3 git branch
- 2.4 git checkout
- 2.5 git cherry-pick
- 2.6 git clone
- 2.7 git config
- 2.8 git commit
- 2.9 git diff
- 2.10 git fetch
- 2.11 git init
- 2.12 git log
- 2.13 git merge
- 2.14 git mv
- 2.15 git pull
- 2.16 git push
- 2.17 git remote
- 2.18 git reset
- 2.19 git revert
- 2.20 git rm
- 2.21 git status
- 2.22 git tag
- 3 REST API
- 3.1 Getting the list of repositories
- 3.2 Creating a repository clone
- 3.3 Initializing a git repository
- 3.4 Removing a clone
- 3.5 Getting repository options
- 3.6 Getting repository option
- 3.7 Updating repository option
- 3.8 Setting repository option
- 3.9 Unsetting repository option
- 3.10 Getting a file content from HEAD
- 3.11 Committing all files in index
- 3.12 Amending a commit
- 3.13 Committing a single file
- 3.14 Merging changes from a remote to HEAD
- 3.15 Cherry-picking a commit
- 3.16 Tagging a commit
- 3.17 Removing a tag
- 3.18 Getting a diff between working tree and index
- 3.19 Getting a diff between index and HEAD
- 3.20 Getting a diff between two commits
- 3.21 Getting a diff location for two commits
- 3.22 Getting file content from index
- 3.23 Unstage all files in the index
- 3.24 Unstaging a group of files
- 3.25 Unstaging a single file
- 3.26 Staging a file
- 3.27 Staging files
- 3.28 Getting the list of remotes
- 3.29 Getting the list of a remote's branches
- 3.30 Getting the remote branch details
- 3.31 Adding a new remote
- 3.32 Fetching changes from a remote
- 3.33 Pushing changes to a remote
- 3.34 Removing remotes
- 3.35 Getting status for a git project
- 3.36 Creating a new tag
- 3.37 Listing tags
- 3.38 Listing branches
- 3.39 Getting branch metadata
- 3.40 Creating a branch
- 3.41 Removing a branch
- 3.42 Checking out a branch
- 3.43 Checking out a tag
- 3.44 Discarding changes in working directory
- 3.45 Listing commits
- 3.46 Listing commits revision or named commits
- 3.47 Getting commit metadata
- 3.48 Getting file content in a commit
- 3.49 Getting blame result from HEAD
- 3.50 Getting blame result from commit
- 4 JSON representations
Resource/HTTP method matrix
Git commands
git add
- #Staging a file
- #Staging files
- #Unstaging a single file
- #Unstaging all files in the index
- #Getting a file content from index
git blame
git branch
git checkout
git cherry-pick
git clone
- #Getting the list of repositories
- #Creating a repository clone
- #Initializing a git repository
- #Removing a clone
git config
- #Getting repository options
- #Getting repository option
- #Updating repository option
- #Setting repository option
- #Unsetting repository option
git commit
git diff
- #Getting a diff between working tree and index
- #Getting a diff between index and HEAD
- #Getting a diff location for two commits
- #Getting a diff between two commits
- #Getting a file content from index
- #Getting a file content from HEAD
git fetch
git init
git log
- #Listing commits
- #Listing commits between two named commits
- #Getting commit metadata
- #Getting file content in a commit
git merge
- #Merging changes from a remote to HEAD
- Squashing changes - see bug 351432
git mv
see bug 349168
git pull
see bug 339114
git push
git remote
- #Getting the list of remotes
- #Getting the list of remote's branches
- #Getting the remote branch details
- #Adding a new remote
- #Removing remote
git reset
git revert
see bug 339105
git rm
see bug 349299
git status
#Getting status for a git project
git tag
REST API
Getting the list of repositories
- Overview
- To get the list of repositories send a GET request to the git clone location.
- HTTP Method
- GET
- Example Request
GET /gitapi/clone/workspace/{:workspace_id}/
- Example Response
HTTP/1.1 200 OK {"Children": [ { "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/", "Location": "http://localhost:8080/gitapi/clone/file/u/", "Name": "sfranklin", "RemoteLocation": "http://localhost:8080/gitapi/remote/file/u/" }, { "BranchLocation": "http://localhost:8080/gitapi/branch/file/q0/", "ConfigLocation": "http://localhost:8080/gitapi/config/clone/file/q0/", "ContentLocation": "http://localhost:8080/file/q0/", "HeadLocation": "http://localhost:8080/gitapi/commit/HEAD/file/q0/", "Location": "http://localhost:8080/gitapi/clone/file/q0/", "Name": "bug349480", "RemoteLocation": "http://localhost:8080/gitapi/remote/file/q0/" } ]}
- Detailed Explanation
- TBD
Creating a repository clone
- Overview
- To create a clone send a POST request to the git clone location.
- HTTP Method
- POST
- Example Request
POST /gitapi/clone/
{
"Location" : "/workspace/{workspace_id}",
"GitUrl" : "{git repo url}",
"GitSshKnownHost" : "{git ssh known host}",
"GitSshUsername" : "{git ssh username}",
"GitSshPassword" : "{git ssh password}",
"GitSshKnownHost" : "{git ssh known host}",
"GitSshPrivateKey" : "{git ssh private key}",
"GitSshPassphrase" : "{git ssh passphrase}"
}
- Example Response
HTTP/1.1 201 CREATED { "Id": "IOOD6ph8ABASBcDqmXX87w", "Location": "http://localhost:8080/task/id/IOOD6ph8ABASBcDqmXX87w", "Message": "Cloning c:\\home\\clones\\testClone...", "PercentComplete": 0, "Running": true }
- Detailed Explanation
- The response contains the location of the git clone task. Call Get on the task location to check the status.
Initializing a git repository
- Overview
- To init a git repository send a POST request to the git clone location. JSON data cannot contain GitUrl field, as it indicates that desired operation is cloning of a repository.
- HTTP Method
- POST
- Example Request
POST /gitapi/clone/
{
"Name" : "{repo_name}",
"Location" : "/workspace/{workspace_id}",
"GitMail" : "{committer e-mail address}",
"GitName" : "{committer name}"
}
- Example Response
HTTP/1.1 201 CREATED { "Location": "http://localhost:8080/git/clone/file/user-OrionContent/repo" }
- Detailed Explanation
- The response contains the location of the initialized git repository. Call Get on this location to obtain more repository details. Request body can contain either "Name" and "Location" fields (a new project with git repository will be created in the given workspace) or "Path" field only (git repository will be created in the given project).
Removing a clone
- Overview
- To delete a clone send a DELETE request to the git clone location.
- HTTP Method
- DELETE
- Example Request
DELETE /gitapi/clone/file/{:workspace_id}/{:repo_dir}/
- Example Response
HTTP/1.1 200 OK
- Detailed Explanation
- No response. The clone and its folder have been deleted.
Getting repository options
- Overview
- To get the list of repository options send a GET request to the git config location.
- HTTP Method
- GET
- Example Request
GET /gitapi/config/clone/file/{:workspace_id}/{:repo_dir}/
- Example Response
HTTP/1.1 200 OK {"Children": [ { "Key": "core.repositoryformatversion", "Location": "http://localhost:8080/gitapi/config/core.repositoryformatversion/clone/file/A/", "Value": ["0"] }, { "Key": "core.filemode", "Location": "http://localhost:8080/gitapi/config/core.filemode/clone/file/A/", "Value": ["false"] }, { "Key": "core.logallrefupdates", "Location": "http://localhost:8080/gitapi/config/core.logallrefupdates/clone/file/A/", "Value": ["true"] }, { "Key": "core.autocrlf", "Location": "http://localhost:8080/gitapi/config/core.autocrlf/clone/file/A/", "Value": ["false"] }, { "Key": "user.name", "Location": "http://localhost:8080/gitapi/config/user.name/clone/file/A/", "Value": ["John"] }, { "Key": "user.email", "Location": "http://localhost:8080/gitapi/config/user.email/clone/file/A/", "Value": ["john@email.com"] } ]}
- Detailed Explanation
- The response contains the list of all repository options. Each option contains its location, which can be used for update or delete operation.
Getting repository option
- Overview
- To get the repository option send a GET request to the git config option location.
- HTTP Method
- GET
- Example Request
GET /gitapi/config/user.name/clone/file/{:workspace_id}/{:repo_dir}/
- Example Response
HTTP/1.1 200 OK { "Key": "user.name", "Location": "http://localhost:8080/gitapi/config/user.name/clone/file/user-OrionContent/repo/", "Value": ["John"] }
- Detailed Explanation
- The response contains the repository option key, value and location.
Updating repository option
- Overview
- To update repository option send a PUT request to the git config option location. POST also can be used, see #Setting repository option.
- HTTP Method
- PUT
- Example Request
PUT /gitapi/config/user.name/clone/file/{:workspace_id}/{:repo_dir}/
{
"Value" : "John"
}
- Example Response
HTTP/1.1 200 OK { "Key": "user.name", "Location": "http://localhost:8080/gitapi/config/user.name/clone/file/user-OrionContent/repo/", "Value": ["John"] }
- Detailed Explanation
- The response contains the repository option key, value and location.
Setting repository option
- Overview
- To set a new repository option send a POST request to the git config location.
- HTTP Method
- POST
- Example Request
POST /gitapi/config/clone/file/{:workspace_id}/{:repo_dir}/
{
"Key" : "user.name",
"Value" : "Alice"
}
- Example Response
HTTP/1.1 201 CREATED { "Key": "user.name", "Location": "http://localhost:8080/gitapi/config/user.name/clone/file/user-OrionContent/repo/", "Value": ["Alice"] }
- Detailed Explanation
- The response contains the repository option key, value and location.
Unsetting repository option
- Overview
- To unset repository option send a DELETE request to the git config option location.
- HTTP Method
- DELETE
- Example Request
DELETE /gitapi/config/user.name/clone/file/{:workspace_id}/{:repo_dir}/
- Example Response
HTTP/1.1 200 OK
- Detailed Explanation
- No response. The repository option has been unset.
Getting a file content from HEAD
- Overview
- To retrieve file content kept in HEAD. Send a GET request to the git commit location.
- HTTP Method
- GET
- Example Request
GET /gitapi/commit/HEAD/file/{:workspace_id}/{:repo_dir}/file.txt
- Example Response
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 22
This is the content.
- Detailed Explanation
- TBD.
Committing all files in index
- Overview
- To commit all files in index. Send a POST request to the git commit location.
- HTTP Method
- POST
- Example Request
POST /gitapi/commit/HEAD/file/{:workspace_id}/{:repo_dir}/
{
"Message" : "fixing bug 349827"
}
- Example Response
HTTP/1.1 200 OK { "AuthorEmail": "Tomasz.Zarna@pl.ibm.com", "AuthorName": "Tomasz Zarna", "Children": [], "CommitterEmail": "Tomasz.Zarna@pl.ibm.com", "CommitterName": "Tomasz Zarna", "ContentLocation": "http://localhost:8080/gitapi/commit/1fe0d121457ec1fc61d86e497576972443cdb14a/file/user-OrionContent/repo/?parts=body", "DiffLocation": "http://localhost:8080/gitapi/diff/1fe0d121457ec1fc61d86e497576972443cdb14a/file/user-OrionContent/repo/", "Diffs": [{ "ChangeType": "MODIFY", "DiffLocation": "http://localhost:8080/gitapi/diff/c47c36518cd8aaf01b84afa55cf9a75badc882d9..1fe0d121457ec1fc61d86e497576972443cdb14a/file/user-OrionContent/repo/folder/file.txt", "NewPath": "folder/file.txt", "OldPath": "folder/file.txt", "Type": "Diff" }], "Location": "http://localhost:8080/gitapi/commit/1fe0d121457ec1fc61d86e497576972443cdb14a/file/user-OrionContent/repo/", "Message": "fixing bug 349827", "Name": "1fe0d121457ec1fc61d86e497576972443cdb14a", "Time": 1308917875000, "Type": "Commit"
}
- Detailed Explanation
- The response will contain a newly created commit.
Amending a commit
- Overview
- To amend the last commit. Send a POST request to the git commit location.
- HTTP Method
- POST
- Example Request
POST /gitapi/commit/HEAD/file/{:workspace_id}/{:repo_dir}/
{
"Message" : "{amended commit message}",
"Amend" : "true",
"ChangeId" : false,
"AuthorName" : "{author name}",
"AuthorEmail" : "{author email}",
"CommitterName" : "{committer name}",
"CommitterEmail" : "{committer email}",
"persist" : false
}
- Example Response
HTTP/1.1 200 OK see #Committing all files in index
- Detailed Explanation
- TBD.
Committing a single file
- Overview
- To commit a single. Send a POST request to the git commit location of that file.
- HTTP Method
- POST
- Example Request
POST /gitapi/commit/HEAD/file/{:workspace_id}/{:repo_dir}/{:file_path}
{
"Message" : "fixing bug 349827"
}
- Example Response
HTTP/1.1 200 OK { "AuthorEmail": "Tomasz.Zarna@pl.ibm.com", "AuthorName": "Tomasz Zarna", "Children": [], "CommitterEmail": "Tomasz.Zarna@pl.ibm.com", "CommitterName": "Tomasz Zarna", "ContentLocation": "http://localhost:8080/gitapi/commit/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/user-OrionContent/repo/test.txt?parts=body", "DiffLocation": "http://localhost:8080/gitapi/diff/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/user-OrionContent/repo/test.txt", "Diffs": [{ "ChangeType": "MODIFY", "DiffLocation": "http://localhost:8080/gitapi/diff/1fe0d121457ec1fc61d86e497576972443cdb14a..91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/user-OrionContent/repo/test.txt", "NewPath": "test.txt", "OldPath": "test.txt", "Type": "Diff" }], "Location": "http://localhost:8080/gitapi/commit/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/user-OrionContent/repo/test.txt", "Message": "fixing bug 349827", "Name": "91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9", "Time": 1308918640000, "Type": "Commit"
}
- Detailed Explanation
- Like when #Committing all files in index the response will contain a newly created commit. The difference is that it's not required the file has been staged.
Merging changes from a remote to HEAD
- Overview
- To merge changes from a remote to HEAD send a POST request to the git commit location.
- HTTP Method
- POST
- Example Request
POST /gitapi/commit/HEAD/file/{:workspace_id}/{:repo_dir}/
{
"Merge" : "{refId}"
}
- Example Response
HTTP/1.1 200 OK
{"Result": "ALREADY_UP_TO_DATE"}
- Detailed Explanation
- TBD.
Cherry-picking a commit
- Overview
- To cherry-pick a commit send a POST request to the git commit location.
- HTTP Method
- POST
- Example Request
POST /gitapi/commit/HEAD/file/{:workspace_id}/{:repo_dir}/
{
"Cherry-Pick" : "e345e82f3e793be3ce872f5784da92f4a9e50007"
}
- Example Response
HTTP/1.1 200 OK
{"Result": "OK", "HeadUpdated" : "true"}
- Detailed Explanation
- When cherry-picking succeeded "OK" is returned. Other possible results are "FAILED" and "CONFLICTING". "HeadUpdated" parameter informs whether HEAD has moved. If trying to cherry-pick a commit which has been already picked, the result will say "OK", but the second param will indicate that nothing has actually changed.
Tagging a commit
- Overview
- To tag a commit send a PUT request to the git commit location.
- HTTP Method
- PUT
- Example Request
PUT /gitapi/commit/(revision)/file/{:workspace_id}/{:repo_dir}/
{
"Name" : "{tag name}"
"Annotated" : "{true or false}"
"Message" : "{annotated tag message}"
}
- Example Response
HTTP/1.1 200 OK Content-Type: text/plain Content-Length: 22 { "AuthorName": "(author)", "Children": ["(tag name)"], "ContentLocation": "http://localhost:8080/git/commit/(revision)/file/user-OrionContent/repo/?parts=body", "DiffLocation": "http://localhost:8080/git/diff/(revision)/file/user-OrionContent/repo/", "Location": "http://localhost:8080/git/commit/(revision)/file/user-OrionContent/repo/", "Message": "(commit message)", "Name": "(commit name)", "Time": 1304073355000 }
- Detailed Explanation
- TBD.
Removing a tag
- Overview
- To deleta a tag a DELETE request to the git tag location.
- HTTP Method
- DELETE
- Example Request
DELETE /gitapi/tag/tag1/file/{:workspace_id}/{:repo_dir}/
- Example Response
HTTP/1.1 200 OK
- Detailed Explanation
- No response. The tag has been removed.
Getting a diff between working tree and index
- Overview
- To retrieve changes between working tree and index. Send a GET request to the git diff location.
- HTTP Method
- GET
- Example Request
GET /gitapi/diff/Default/file/{:workspace_id}/{:repo_dir}/
Orion-Version: 1.0
- Example Response
HTTP/1.1 HTTP/1.1 200 OK Content-Type: multipart/related; boundary="BOUNDARY" ETag: "35fd43td3" --BOUNDARY Content-Type: application/json { "Base":"http://localhost:8080/git/index/file/repo/a.txt", "Location":"http://localhost:8080/git/diff/Default/file/repo/a.txt", "New":"http://localhost:8080/file/repo/a.txt", "Old":"http://localhost:8080/git/index/file/repo/a.txt", "Type":"Diff" } --BOUNDARY Content-Type: plain/text diff --git a/a.txt b/a.txt index 380e08d..bbfd849 100644 --- a/a.txt +++ b/a.txt @@ -1,3 +1,4 @@ fdsfdsafdsad asasasa2d -Elod +Elod +Something
- Detailed Explanation
- The diff and related uris are returned as a single multi-part response. You may use query parts=uris or parts=diff to get only one part of the response.
Getting a diff between index and HEAD
- Overview
- To retrieve changes between index and HEAD. Send a GET request to the git diff location.
- HTTP Method
- GET
- Example Request
GET /gitapi/diff/Cached/file/{:workspace_id}/{:repo_dir}/
Orion-Version: 1.0
- Example Response
HTTP/1.1 HTTP/1.1 200 OK Content-Type: multipart/related; boundary="BOUNDARY" ETag: "35fd43td3" --BOUNDARY Content-Type: application/json { "Base":"http://localhost:8080/git/index/file/repo/a.txt", "Diff":"http://localhost:8080/git/diff/Default/file/repo/a.txt", "New":"http://localhost:8080/file/repo/a.txt", "Old":"http://localhost:8080/git/index/file/repo/a.txt", "Type":"Diff" } --BOUNDARY Content-Type: plain/text diff --git a/a.txt b/a.txt index 380e08d..bbfd849 100644 --- a/a.txt +++ b/a.txt @@ -1,3 +1,4 @@ fdsfdsafdsad asasasa2d -Elod +Elod +Something
- Detailed Explanation
- The diff and related uris are returned as a single multi-part response. You may use query parts=uris or parts=diff to get only one part of the response.
Getting a diff between two commits
- Overview
- To retrieve changes between two commits. Send a GET request to the git diff location.
- HTTP Method
- GET
- Example Request
GET /gitapi/diff/{:old revision}..{:new revision}/file/{:workspace_id}/{:repo_dir}/?parts={:diffs/uris}&pageSize={:page_size}&page={:page_number}
Orion-Version: 1.0
- Example Response
HTTP/1.1 HTTP/1.1 200 OK Content-Type: multipart/related; boundary="BOUNDARY" ETag: "35fd43td3" --BOUNDARY Content-Type: application/json { "Base":"http://localhost:8080/git/index/file/repo/a.txt", "Location":"http://localhost:8080/git/diff/Default/file/repo/a.txt", "New":"http://localhost:8080/file/repo/a.txt", "Old":"http://localhost:8080/git/index/file/repo/a.txt", "Type":"Diff" } --BOUNDARY Content-Type: plain/text diff --git a/a.txt b/a.txt index 380e08d..bbfd849 100644 --- a/a.txt +++ b/a.txt @@ -1,3 +1,4 @@ fdsfdsafdsad asasasa2d -Elod +Elod +Something
- Detailed Explanation
- If query parameter "parts=diffs" then "pageSize" and "page" must also be specified.
Getting a diff location for two commits
- Overview
- To get a diff location for two commits. Send a POST request to the git diff location for old commit.
- HTTP Method
- POST
- Example Request
POST /gitapi/diff/{:old revision}/file/{:workspace_id}/{:repo_dir}/{:file_path}
{
"New" : "{new revision}"
}
- Example Response
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 22
Location: /git/diff/{old revision}..{new revision}/file/repo/
<nothing>
- Detailed Explanation
- TBD.
Getting file content from index
- Overview
- To retrieve file content kept in index. Send a GET request to the git index location.
- HTTP Method
- GET
- Example Request
GET /gitapi/index/file/{:workspace_id}/{:repo_dir}/{:file_path}
- Example Response
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 22
This is the content from index.
- Detailed Explanation
- TBD.
Unstage all files in the index
- Overview
- To unstage all previously-staged files, reset index and/or working tree. Send a POST request to the git index location.
- HTTP Method
- POST
- Example Request
POST /gitapi/index/file/{:workspace_id}/{:repo_dir}/
{
"Reset" : "MIXED"
}
- Example Response
HTTP/1.1 200 OK
- Detailed Explanation
- No response body. Subsequent request for git status will show that all staged files are now unstaged.
Unstaging a group of files
- Overview
- To unstage a group of files. Send a POST request to the git index location.
- HTTP Method
- POST
- Example Request
POST /gitapi/index/file/{:workspace_id}/{:repo_dir}/
{
"Path" : ["folder/file.txt", "file1.txt" ]
}
- Example Response
HTTP/1.1 200 OK
- Detailed Explanation
- No response body. Subsequent request for git status will show that the files have been unstaged.
Unstaging a single file
- Overview
- To unstage an individual file. Send a POST request to the git index location.
- HTTP Method
- POST
- Example Request
POST /gitapi/index/file/{:workspace_id}/{:repo_dir}/file.txt
- Example Response
HTTP/1.1 200 OK
- Detailed Explanation
- No response body. Subsequent request for git status will show that the file has been unstaged.
Staging a file
- Overview
- To stage a file, add it to the index. Send a PUT request to the git index location.
- HTTP Method
- PUT
- Example Request
PUT /gitapi/index/file/{:workspace_id}/{:repo_dir}/{:file_path}
- Example Response
HTTP/1.1 200 OK
- Detailed Explanation
- No response body, see #Getting status for a git project to verify the file has been added to index.
Staging files
- Overview
- To stage multiple files, add them to the index. Send a PUT request to the git index location.
- HTTP Method
- PUT
- Example Request
PUT /gitapi/index/file/{:workspace_id}/{:repo_dir}/
{
"Path" : ["file1.txt", "folder/file.txt"]
}
- Example Response
HTTP/1.1 200 OK
- Detailed Explanation
- No response body, see #Getting status for a git project to verify all files have been added to index.
Getting the list of remotes
- Overview
- To get the list of remotes send a GET request to the git remote location.
- HTTP Method
- GET
- Example Request
GET /gitapi/remote/file/{:workspace_id}/{:repo_dir}/
- Example Response
HTTP/1.1 200 OK { "Children": [ { "CloneLocation": "/gitapi/clone/file/user-OrionContent/repo/orion.client/", "GitUrl": "https://github.com/user/orion.client.git", "IsGerrit": false, "Location": "/gitapi/remote/origin/file/user-OrionContent/repo/orion.client/", "Name": "origin", "Type": "Remote" }, { "CloneLocation": "/gitapi/clone/file/user-OrionContent/repo/orion.client/", "GitUrl": "http://git.eclipse.org/gitroot/orion/org.eclipse.orion.client.git", "IsGerrit": false, "Location": "/gitapi/remote/upstream/file/user-OrionContent/repo/orion.client/", "Name": "upstream", "Type": "Remote" } ], "Type": "Remote"
}
- Detailed Explanation
- TBD
Getting the list of a remote's branches
- Overview
- To get the list of a remote's branches send a GET request to the git remote location.
- HTTP Method
- GET
- Example Request
GET /gitapi/remote/{:remote}/file/{:workspace_id}/{:repo_dir}/
- Example Response
HTTP/1.1 200 OK { "Children": [{ "CommitLocation": "http://localhost:8080/git/commit/bbbcc34fe10c2d731e7f97618f4f469c2f763a31/file/repo/", "Id": "bbbcc34fe10c2d731e7f97618f4f469c2f763a31", "Location": "http://localhost:8080/git/remote/origin/master/file/repo/", "Name": "refs/remotes/origin/master" }], "Location": "http://localhost:8080/git/remote/origin/file/repo/", "Name": "origin" }
- Detailed Explanation
- TBD
Getting the remote branch details
- Overview
- To get the remote branch details send a GET request to the git remote location.
- HTTP Method
- GET
- Example Request
GET /gitapi/remote/{:remote}/{:branch}/file/{:workspace_id}/{:repo_dir}/
- Example Response
HTTP/1.1 200 OK { "CommitLocation": "http://localhost:8080/git/commit/bbbcc34fe10c2d731e7f97618f4f469c2f763a31/file/repo/", "HeadLocation": "http://localhost:8080/git/commit/HEAD/file/repo/", "Id": "bbbcc34fe10c2d731e7f97618f4f469c2f763a31", "Location": "http://localhost:8080/git/remote/origin/master/file/repo/" }
- Detailed Explanation
- TBD
Adding a new remote
- Overview
- To add a new remote send a POST request to the git remote location.
- HTTP Method
- POST
- Example Request
POST /gitapi/remote/file/{:workspace_id}/{:repo_dir}/
{
"Remote" : "{remote name}",
"RemoteURI" : "{remote URI}",
"FetchRefSpec" : "{fetch refspec - optional}",
"PushURI" : "{remote push URI - optional}",
"PushRefSpec" : "{push refspec - optional}"
}
- Example Response
HTTP/1.1 201 CREATED Location: http://localhost:8080/git/remote/newremote/file/repo/ Content-Type: application/json { "Location": "http://localhost:8080/git/remote/newremote/file/repo/" }
}
- Detailed Explanation
- The response contain the location of the new remote.
Fetching changes from a remote
- Overview
- To fetch changes from a remote send a POST request to the git branch location.
- HTTP Method
- POST
- Example Request
POST /gitapi/remote/{:remote}/{:branch}/file/{:workspace_id}/{:repo_dir}/
{
"Fetch" : "true",
"GitSshKnownHost" : "{git ssh known host}",
"GitSshUsername" : "{git ssh username}",
"GitSshPassword" : "{git ssh password}",
"GitSshPrivateKey" : "{git ssh private key}",
"GitSshPassphrase" : "{git ssh passphrase}"
}
- Example Response
HTTP/1.1 201 CREATED { "Id": "QEHCv6J8ABASBcDqmXX87w", "Location": "http://localhost:8080/task/id/QEHCv6J8ABASBcDqmXX87w", "Message": "Fetching origin...", "PercentComplete": 0, "Running": true }
- Detailed Explanation
- The response contain the location of the git fetch task. Call Get on the task location to check the status.
Pushing changes to a remote
- Overview
- To push changes from a remote send a POST request to the git branch location.
- HTTP Method
- POST
- Example Request
POST /gitapi/remote/{:remote}/{:branch}/file/{:workspace_id}/{:repo_dir}/
{
"PushSrcRef" : "HEAD",
"PushTags" : "true",
"Force" : "false",
"GitSshKnownHost" : "{git ssh known host}",
"GitSshUsername" : "{git ssh username}",
"GitSshPassword" : "{git ssh password}",
"GitSshPrivateKey" : "{git ssh private key}",
"GitSshPassphrase" : "{git ssh passphrase}"
}
- Example Response
HTTP/1.1 201 CREATED { "Id": "YLhATqR8ABASBcDqmXX87w", "Location": "http://localhost:8080/task/id/YLhATqR8ABASBcDqmXX87w", "Message": "Pushing origin...", "PercentComplete": 0, "Running": true }
- Detailed Explanation
- The response contain the location of the git push task. Call Get on the task location to check the status.
Removing remotes
- Overview
- To delete the remote send a DELETE request to the git remote location.
- HTTP Method
- DELETE
- Example Request
DELETE /gitapi/remote/{:remote}/file/{:workspace_id}/{:repo_dir}/
- Example Response
HTTP/1.1 200 OK
- Detailed Explanation
- HTTP status code 200 OK is returned, when the remote is successfully removed.
Getting status for a git project
- Overview
- To retrieve the working tree status of a project, send a GET request to the git status location.
- HTTP Method
- GET
- Example Request
GET /gitapi/status/file/{:workspace_id}/{:repo_dir}/
- Example Response
HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Content-Length: 468 { "Added": [], "Changed": [], "CommitLocation": "http://localhost:8080/git/commit/HEAD/file/repo/", "Conflicting": [], "IndexLocation": "http://localhost:8080/git/index/file/repo/", "Missing": [], "Modified": [{ "Git": { "CommitLocation": "http://localhost:8080/git/commit/HEAD/file/repo/a.txt", "DiffLocation": "http://localhost:8080/git/diff/Default/file/repo/a.txt", "IndexLocation": "http://localhost:8080/git/index/file/repo/a.txt" }, "Location": "http://localhost:8080/file/repo/a.txt", "Name": "a.txt", "Path": "a.txt" }], "Removed": [], "Untracked": [] }
- Detailed Explanation
- "IndexLocation" can be used to add all files to index, "CommitLocation" can be used to commit all files.
Creating a new tag
- Overview
- To tag a commit send a PUT request to the git tag location.
- HTTP Method
- PUT
- Example Request
PUT /gitapi/commit/{:refId}/file/{:workspace_id}/{:repo_dir}
{
"Name" : "{tag name}",
"Annotated" : boolean,
"Message" : "{annotated message}",
}
- Example Response
HTTP/1.1 201 CREATED
Content-Type: text/plain
Content-Length: 22
TBD
- Detailed Explanation
- TBD
Listing tags
- Overview
- To get the list of tags send a GET request to the git tag location.
- HTTP Method
- GET
- Example Request
GET /gitapi/tag/file/{:workspace_id}/{:repo_dir}/
- Example Response
HTTP/1.1 200 OK
{
"Children": [
{
"FullName": "refs/tags/v20110606",
"Name": "v20110606"
},
{
"FullName": "refs/tags/v20110607",
"Name": "v20110607"
},
{
"FullName": "refs/tags/R0_2M4",
"Name": "vR0_2M4"
}
]}
- Detailed Explanation
- The response contains list of all tags for the given repository.
Listing branches
- Overview
- To get the list of branches send a GET request to the git tag location.
- HTTP Method
- GET
- Example Request
GET /gitapi/branch/file/{:workspace_id}/{:repo_dir}/
- Example Response
HTTP/1.1 200 OK { "Children": [ { "CloneLocation": "http://localhost:8080/gitapi/clone/file/repo/", "CommitLocation": "http://localhost:8080/gitapi/commit/master/file/repo/", "Current": true, "HeadLocation": "http://localhost:8080/gitapi/commit/HEAD/file/repo/", "Location": "http://localhost:8080/gitapi/branch/master/file/repo/", "Name": "master", "RemoteLocation": "http://localhost:8080/gitapi/remote/origin/master/file/repo/", "Type": "Branch" }, { "CloneLocation": "http://localhost:8080/gitapi/clone/file/repo/", "CommitLocation": "http://localhost:8080/gitapi/commit/dev/file/repo/", "Current": false, "HeadLocation": "http://localhost:8080/gitapi/commit/HEAD/file/repo/", "Location": "http://localhost:8080/gitapi/branch/dev/file/repo/", "Name": "dev", "RemoteLocation": "http://localhost:8080/gitapi/remote/origin/dev/file/repo/", "Type": "Branch" } ]}
- Detailed Explanation
- The response contains list of all local branches for the current repository. An active branch will have "Current" property set to true.
Getting branch metadata
- Overview
- To get more info about a branch send a GET request to its git branch location.
- HTTP Method
- GET
- Example Request
GET /gitapi/branch/master/file/{:workspace_id}/{:repo_dir}/
- Example Response
HTTP/1.1 200 OK { "CloneLocation": "http://localhost:8080/gitapi/clone/file/repo/", "CommitLocation": "http://localhost:8080/gitapi/commit/master/file/repo/", "Current": true, "DiffLocation": "http://localhost:8080/gitapi/diff/master/file/repo/", "FullName": "refs/heads/master", "HeadLocation": "http://localhost:8080/gitapi/commit/HEAD/file/repo/", "LocalTimeStamp": 1234567890000, "Location": "http://localhost:8080/gitapi/branch/master/file/repo/", "Name": "master", "RemoteLocation": ["http://localhost:8080/gitapi/remote/origin/master/file/repo/"], "TreeLocation": "http://localhost:8080/gitapi/tree/file/repo/master", "Type": "Branch" }
- Detailed Explanation
- The response contains details of the selected local branch.
Creating a branch
- Overview
- To create a local send a POST request to the git BranchLocation. The data must be JSON.
- HTTP Method
- POST
- Example Request
POST /gitapi/branch/file/{:workspace_id}/{:repo_dir}/
{
"Name" : "dev",
"Branch" : "{starting point}" (if omitted the current HEAD will be used)
}
- Example Response
HTTP/1.1 201 CREATED { "CloneLocation": "http://localhost:8080/gitapi/clone/file/repo/", "CommitLocation": "http://localhost:8080/gitapi/commit/dev/file/repo/", "Current": false, "HeadLocation": "http://localhost:8080/gitapi/commit/HEAD/file/repo/", "Location": "http://localhost:8080/gitapi/branch/dev/file/repo/", "Name": "dev", "RemoteLocation": "http://localhost:8080/gitapi/remote/origin/dev/file/repo/", "Type": "Branch" }
- Detailed Explanation
- The response contain the newly created branch. Note this is not an active branch yet. You need to check it out first, see #Checking out a branch.
Removing a branch
- Overview
- To remove a local branch send a DELETE request to its git branch location.
- HTTP Method
- DELETE
- Example Request
DELETE /gitapi/branch/master/file/{:workspace_id}/{:repo_dir}/
- Example Response
HTTP/1.1 200 OK
- Detailed Explanation
- The response is empty. Subsequent calls on the branch location will return 404 NOT FOUND.
Checking out a branch
- Overview
- To checkout a branch send a PUT request to the git clone Location. The data must be JSON.
- HTTP Method
- PUT
- Example Request
PUT /gitapi/clone/file/{:workspace_id}/{:repo_dir}/
{
"Branch" : "dev"
}
- Example Response
HTTP/1.1 200 OK
- Detailed Explanation
- No response body, but subsequent requests for branch details will indicate that 'dev' is now an active (current) branch.
Checking out a tag
- Overview
- To checkout a tag send a PUT request to the git clone location. A new branch will be created for the requested tag.
- HTTP Method
- PUT
- Example Request
PUT /gitapi/clone/file/{:workspace_id}/{:repo_dir}/
{
"Tag" : "stable"
"Branch" : "tag_stable"
}
- Example Response
HTTP/1.1 200 OK
- Detailed Explanation
- No response body, but subsequent requests for branch details will indicate that 'tag_stable' is now an active (current) branch. Until http://egit.eclipse.org/r/#change,4336 is resolved, the branch name should be different than the tag.
Discarding changes in working directory
- Overview
- To checkout a file send a PUT request to the git clone location.
- HTTP Method
- PUT
- Example Request
PUT /gitapi/clone/file/{:workspace_id}/{:repo_dir}/
{
"Path" : ["folder/file.txt"]
}
- Example Response
HTTP/1.1 200 OK
- Detailed Explanation
- No response body, but subsequent request for the file content will show that its content has been replaced with the index.
Listing commits
- Overview
- To get list of commits (log) send a GET request to the HeadLocation.
- HTTP Method
- GET
- Example Request
GET /gitapi/commit/HEAD/file/{:workspace_id}/{:repo_dir}/?parts=log
- Example Response
HTTP/1.1 200 OK { "Children": [ { "AuthorEmail": "Tomasz.Zarna@pl.ibm.com", "AuthorName": "Tomasz Zarna", "Children": [], "CommitterEmail": "Tomasz.Zarna@pl.ibm.com", "CommitterName": "Tomasz Zarna", "ContentLocation": "http://localhost:8080/gitapi/commit/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/repo/?parts=body", "DiffLocation": "http://localhost:8080/gitapi/diff/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/repo/", "Diffs": [{ "ChangeType": "MODIFY", "DiffLocation": "http://localhost:8080/gitapi/diff/1fe0d121457ec1fc61d86e497576972443cdb14a..91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/repo/test.txt", "NewPath": "test.txt", "OldPath": "test.txt", "Type": "Diff" }], "Location": "http://localhost:8080/gitapi/commit/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/repo/", "Message": "fixing bug 349827", "Name": "91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9", "Time": 1308918640000, "Type": "Commit" } ], "RepositoryPath": "", "toRef": { "CloneLocation": "http://localhost:8080/gitapi/clone/file/repo/", "CommitLocation": "http://localhost:8080/gitapi/commit/master/file/repo/", "Current": true, "HeadLocation": "http://localhost:8080/gitapi/commit/HEAD/file/repo/", "Location": "http://localhost:8080/gitapi/branch/master/file/repo/", "Name": "master", "Type": "Branch" }
}
- Detailed Explanation
- The response contains list of commits (see response for #Committing all files in index) and details about refs used in the log when available.
There is also an alternative API where (I guess ?parts=log is replaced by) ?page=page_no&pageSize=page_size. In the response you'll get NextLocation and PreviousLocation that will direct you to the next and previous page.
Listing commits revision or named commits
- Overview
- To get list of commits (log) using a revision. If revision is "master..myBranch", the response will be the commits on myBranch since it was branched from master. If revision is "master~4..master", the response will be the 4 most recent commits on master; if there are less than 4, the result will be status 400 error.
- HTTP Method
- GET
- Example Request
GET /gitapi/commit/master~4..master/file/{:workspace_id}/{:repo_dir}
- Example Response
HTTP/1.1 200 OK { "Children": [ { "AuthorEmail": "Tomasz.Zarna@pl.ibm.com", "AuthorName": "Tomasz Zarna", "Children": [], "CommitterEmail": "Tomasz.Zarna@pl.ibm.com", "CommitterName": "Tomasz Zarna", "ContentLocation": "http://localhost:8080/gitapi/commit/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/repo/?parts=body", "DiffLocation": "http://localhost:8080/gitapi/diff/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/repo/", "Diffs": [{ "ChangeType": "MODIFY", "DiffLocation": "http://localhost:8080/gitapi/diff/1fe0d121457ec1fc61d86e497576972443cdb14a..91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/repo/test.txt", "NewPath": "test.txt", "OldPath": "test.txt", "Type": "Diff" }], "Location": "http://localhost:8080/gitapi/commit/91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9/file/repo/", "Message": "fixing bug 349827", "Name": "91e0cd59fcf0be00fb9d2469e4eb06e7620e97c9", "Time": 1308918640000, "Type": "Commit" } ], "RepositoryPath": "", "toRef": { "CloneLocation": "http://localhost:8080/gitapi/clone/file/repo/", "CommitLocation": "http://localhost:8080/gitapi/commit/master/file/repo/", "Current": true, "HeadLocation": "http://localhost:8080/gitapi/commit/HEAD/file/repo/", "Location": "http://localhost:8080/gitapi/branch/master/file/repo/", "Name": "master", "Type": "Branch" }
}
- Detailed Explanation
- The response contains an array of commits on the Children property.
Getting commit metadata
- Overview
- To get details of a commit send a GET request to git commit location.
- HTTP Method
- GET
- Example Request
GET /gitapi/commit/c47c36518cd8aaf01b84afa55cf9a75badc882d9/file/{:workspace_id}/{:repo_dir}/{:file_path}
- Example Response
HTTP/1.1 200 OK { "Children": [{ "AuthorEmail": "Tomasz.Zarna@pl.ibm.com", "AuthorName": "Tomasz Zarna", "Children": [], "CommitterEmail": "Tomasz.Zarna@pl.ibm.com", "CommitterName": "Tomasz Zarna", "ContentLocation": "http://localhost:8080/gitapi/commit/c47c36518cd8aaf01b84afa55cf9a75badc882d9/file/filepath/?parts=body", "DiffLocation": "http://localhost:8080/gitapi/diff/c47c36518cd8aaf01b84afa55cf9a75badc882d9/file/filepath/", "Location": "http://localhost:8080/gitapi/commit/c47c36518cd8aaf01b84afa55cf9a75badc882d9/file/filepath/", "Message": "initial commit\n", "Name": "c47c36518cd8aaf01b84afa55cf9a75badc882d9", "Time": 1308667721000, "Type": "Commit" }], "RepositoryPath": ""
}
- Detailed Explanation
- The response contains details for the selected commit.
Getting file content in a commit
- Overview
- To retrieve file content kept for a specific commit. Send a GET request to the git commit location.
- HTTP Method
- GET
- Example Request
GET /gitapi/commit/c47c36518cd8aaf01b84afa55cf9a75badc882d9/file/{:workspace_id}/{:repo_dir}/{:file_path}?parts=body
- Example Response
HTTP/1.1 200 OK
I'm content of file.txt
- Detailed Explanation
- The response contains content of the selected file in the given commit.
Getting blame result from HEAD
- Overview
- Retrieve blame information for the specified file from HEAD.
- HTTP Method
- GET
- Example Request
GET /gitapi/blame/HEAD/file/{:workspace_id}/{:repo_dir}/{:file_path}
- Example Response
HTTP/1.1 200 OK { "Children": [ { "AuthorEmail": "author@email.com ", "AuthorImage": "http://www.gravatar.com/avatar/677bc1ca5ef557ab8f9c94038c0312b7?d=mm", "AuthorName": "Author Name", "CommitLocation": "/gitapi/commit/4065d87b7a839f41d9be40ca11b7ad2f78784bcc/file/location/", "Message": "commit message", "Name": "4065d87b7a839f41d9be40ca11b7ad2f78784bcc", "Time": 1367897569, "Children": [ { "Start": "1", "End": "4" }, { "Start": "7", "End": "8" }, ... ] }, ... ], "CloneLocation": "/gitapi/clone/file/location/", "Location": "/gitapi/blame/HEAD/file/Name/location/file.js", "Type": "Blame" }
- Detailed Explanation
- The response contains all of the information needed to generate blame for the current file. Each commit that appears in the file's blame information resides in the responses' children. For each commit the author's name, email and Gravatar image link are included, along with the commit's location, message, name and time. Each commit also contains an array of line ranges which are blamed to this commit.
Getting blame result from commit
- Overview
- Retrieve blame information for the specified file for a commit.
- HTTP Method
- GET
- Example Request
GET /gitapi/blame/{:sha}/file/{:workspace_id}/{:repo_dir}/{:file_path}
- Example Response
HTTP/1.1 200 OK { "Children": [ { "AuthorEmail": "author@email.com ", "AuthorImage": "http://www.gravatar.com/avatar/677bc1ca5ef557ab8f9c94038c0312b7?d=mm", "AuthorName": "Author Name", "CommitLocation": "/gitapi/commit/af15c87b26c75263c005db59fb1513190b05c3f1/file/location/", "Message": "commit message", "Name": "af15c87b26c75263c005db59fb1513190b05c3f1", "Time": 1367894569, "Children": [ { "Start": "1", "End": "3" }, { "Start": "7", "End": "8" }, ... ] }, ... ], "CloneLocation": "/gitapi/clone/file/location/", "Location": "/gitapi/blame/HEAD/file/Name/location/file.js", "Type": "Blame" }
- Detailed Explanation
- The response contains the blame information for a file for a certain commit. See #Getting blame result from HEAD
JSON representations
File representation extension
The JSON representation for files and directories used by file API may be extended as follows: Required fields are shown in bold. A client cannot rely on the existence of non-required attribute in a file representation from a given Orion server.
Field | Data type | Value |
---|---|---|
Git.CommitLocation | URI | Location of Git Commit resource (HEAD) |
Git.DefaultRemotebranchLocation | URI | Location of the default remote branch |
Git.DiffLocation | URI | Location of Git Diff resource |
Git.IndexLocation | URI | Location of Git Index resource |
Git.RemoteLocation | URI | Location of Git Remote resource |
Git.StatusLocation | URI | Location of Git Status resource |
Git.TagLocation | URI | Location of Git Tag resource |