Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Orion/Server API/Git API"

(REST API)
(REST API)
Line 77: Line 77:
 
=== /git/commit/ ===
 
=== /git/commit/ ===
  
=== Getting status for a git project ===
+
==== Getting a file content from HEAD ====
  
 
{{Orion/ServerAPI
 
{{Orion/ServerAPI
 
| 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 file content kept in HEAD. Send a GET request to the git commit location.
| reqhead = /git/status/file/A/folder/
+
| reqhead = /git/commit/HEAD/file/MyProj/file.txt
 
| resphead = 200 OK
 
| resphead = 200 OK
   Content-Type: application/json; charset=UTF-8
+
   Content-Type: text/plain
   Content-Length: 468
+
   Content-Length: 22
 
| respbody =   
 
| respbody =   
   {
+
   This is the content.
  "Added": [],
+
| explain = TBD.
  "Changed": [],
+
  "Missing": [],
+
  "Modified": [{
+
    "Git": {
+
      "CommitLocation": "http://localhost:8080/git/commit/HEAD/file/A/file.txt",
+
      "DiffLocation": "http://localhost:8080/git/diff/Default/file/A/file.txt",
+
      "IndexLocation": "http://localhost:8080/git/index/file/A/file.txt"
+
    },
+
    "Location": "http://localhost:8080/file/A/file.txt",
+
    "Name": "file.txt",
+
    "Path": "../file.txt"
+
  }],
+
  "Removed": [],
+
  "Untracked": [],
+
  "IndexLocation" : "http://localhost:8080/git/index/file/A/",
+
  "CommitLocation" : "http://localhost:8080/git/commit/HEAD/file/A/"
+
  }
+
| explain = "IndexLocation" can be used to add all files to index, "CommitLocation" can be used to commit all files.
+
 
}}
 
}}
  
=== Getting a diff between working tree and index ===
+
==== Committing files in index ====
 +
 
 +
{{Orion/ServerAPI
 +
| method = POST
 +
| overview = To commit all files in index. Send a POST request to the git commit location.
 +
| reqhead = /git/commit/file/MyProj/
 +
| reqbody = {
 +
"Message" : "<Your commit message>"
 +
}
 +
| resphead = 200 OK
 +
  Content-Type: text/plain
 +
  Content-Length: 22
 +
| respbody = 
 +
  <nothing>
 +
| explain = TBD.
 +
}}
 +
 
 +
==== Amending a commit ====
 +
 
 +
{{Orion/ServerAPI
 +
| method = POST
 +
| overview = To amend the last commit. Send a POST request to the git commit location.
 +
| reqhead = /git/commit/file/MyProj/
 +
| reqbody = {
 +
"Message" : "<Your commit message>",
 +
"Amend" : "true"
 +
}
 +
| resphead = 200 OK
 +
  Content-Type: text/plain
 +
  Content-Length: 22
 +
| respbody = 
 +
  <nothing>
 +
| explain = TBD.
 +
}}
 +
 
 +
This operation is not yet supported, see [https://bugs.eclipse.org/bugs/show_bug.cgi?id=339242 bug 339242].
 +
 
 +
 
 +
=== /git/diff/ ===
 +
 
 +
==== Getting a diff between working tree and index ====
  
 
{{Orion/ServerAPI
 
{{Orion/ServerAPI
Line 123: Line 145:
 
}}
 
}}
  
=== Getting a diff between index and HEAD ===
+
==== Getting a diff between index and HEAD ====
  
 
{{Orion/ServerAPI
 
{{Orion/ServerAPI
Line 137: Line 159:
 
}}
 
}}
  
=== Getting a diff location for two commits ===
+
==== Getting a diff location for two commits ====
  
 
{{Orion/ServerAPI
 
{{Orion/ServerAPI
Line 155: Line 177:
 
}}
 
}}
  
=== Getting a diff between two commits ===
+
==== Getting a diff between two commits ====
  
 
{{Orion/ServerAPI
 
{{Orion/ServerAPI
Line 169: Line 191:
 
}}
 
}}
  
=== Getting a file content from index ===
+
=== /git/config/ ===
  
{{Orion/ServerAPI
+
==== Configuring git ====
| method = GET
+
| overview = To retrieve file content kept in index. Send a GET request to the git index location.
+
| reqhead = /git/index/file/MyProj/file.txt
+
| resphead = 200 OK
+
  Content-Type: text/plain
+
  Content-Length: 22
+
| respbody =  
+
  This is the content from index.
+
| explain = TBD.
+
}}
+
  
 +
Progress is being tracked on [https://bugs.eclipse.org/bugs/show_bug.cgi?id=337820 bug 337820].
  
Progress is being tracked on [https://bugs.eclipse.org/bugs/show_bug.cgi?id=337212 bug 337212].
+
=== /git/index/ ===
  
=== Getting a file content from HEAD ===
+
==== Getting a file content from index ====
  
 
{{Orion/ServerAPI
 
{{Orion/ServerAPI
 
| 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 index. Send a GET request to the git index location.
| reqhead = /git/commit/HEAD/file/MyProj/file.txt
+
| reqhead = /git/index/file/MyProj/file.txt
 
| resphead = 200 OK
 
| resphead = 200 OK
 
   Content-Type: text/plain
 
   Content-Type: text/plain
 
   Content-Length: 22
 
   Content-Length: 22
 
| respbody =   
 
| respbody =   
   This is the content.
+
   This is the content from index.
 
| explain = TBD.
 
| explain = TBD.
 
}}
 
}}
  
=== Configuring git ===
+
==== Staging files ====
 
+
Progress is being tracked on [https://bugs.eclipse.org/bugs/show_bug.cgi?id=337820 bug 337820].
+
 
+
=== Staging files ===
+
  
 
{{Orion/ServerAPI
 
{{Orion/ServerAPI
Line 219: Line 228:
  
  
=== Unstaging files ===
+
==== Unstaging files ====
  
 
{{Orion/ServerAPI
 
{{Orion/ServerAPI
Line 238: Line 247:
 
Progress is being tracked on [https://bugs.eclipse.org/bugs/show_bug.cgi?id=338202 bug 338202].
 
Progress is being tracked on [https://bugs.eclipse.org/bugs/show_bug.cgi?id=338202 bug 338202].
  
=== Committing files in index ===
 
  
{{Orion/ServerAPI
+
Progress is being tracked on [https://bugs.eclipse.org/bugs/show_bug.cgi?id=337212 bug 337212].
| method = POST
+
 
| overview = To commit all files in index. Send a POST request to the git commit location.
+
=== /git/status/ ===
| reqhead = /git/commit/file/MyProj/
+
| reqbody = {
+
"Message" : "<Your commit message>"
+
}
+
| resphead = 200 OK
+
  Content-Type: text/plain
+
  Content-Length: 22
+
| respbody =  
+
  <nothing>
+
| explain = TBD.
+
}}
+
  
=== Amending a commit ===
+
==== Getting status for a git project ====
  
 
{{Orion/ServerAPI
 
{{Orion/ServerAPI
| method = POST
+
| method = GET
| overview = To amend the last commit. Send a POST request to the git commit location.
+
| overview = To retrieve the working tree status of a project, send a GET request to the git status location.
| reqhead = /git/commit/file/MyProj/
+
| reqhead = /git/status/file/A/folder/
| reqbody = {
+
"Message" : "<Your commit message>",
+
"Amend" : "true"
+
}
+
 
| resphead = 200 OK
 
| resphead = 200 OK
   Content-Type: text/plain
+
   Content-Type: application/json; charset=UTF-8
   Content-Length: 22
+
   Content-Length: 468
 
| respbody =   
 
| respbody =   
   <nothing>
+
   {
| explain = TBD.
+
  "Added": [],
 +
  "Changed": [],
 +
  "Missing": [],
 +
  "Modified": [{
 +
    "Git": {
 +
      "CommitLocation": "http://localhost:8080/git/commit/HEAD/file/A/file.txt",
 +
      "DiffLocation": "http://localhost:8080/git/diff/Default/file/A/file.txt",
 +
      "IndexLocation": "http://localhost:8080/git/index/file/A/file.txt"
 +
    },
 +
    "Location": "http://localhost:8080/file/A/file.txt",
 +
    "Name": "file.txt",
 +
    "Path": "../file.txt"
 +
  }],
 +
  "Removed": [],
 +
  "Untracked": [],
 +
  "IndexLocation" : "http://localhost:8080/git/index/file/A/",
 +
  "CommitLocation" : "http://localhost:8080/git/commit/HEAD/file/A/"
 +
  }
 +
| explain = "IndexLocation" can be used to add all files to index, "CommitLocation" can be used to commit all files.
 
}}
 
}}
 
This operation is not yet supported, see [https://bugs.eclipse.org/bugs/show_bug.cgi?id=339242 bug 339242].
 
  
 
= JSON representations =
 
= JSON representations =

Revision as of 06:57, 12 May 2011

The Git API is a web server API for browsing and manipulating Git repositories.

Warning2.png
git URIs format change
Please note, that once bug 339854 is fixed all URIs listed below will have a slightly different form. I will try to update the page ASAP.


Git commands

git add

git branch

see bug 341384

git checkout

see bug 337818

git clone

see bug 337818

git config

#Configuring git

git commit

git diff

git fetch

see bug 339110

git log

see bug 339104

git merge

see bug 339111

git pull

see bug 339114

git push

see bug 339115

git remote

see bug 339109

git reset

see bug 338202

git revert

see bug 339105

git status

#Getting status for a git project

git tag

see bug 339108

REST API

/git/commit/

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 /git/commit/HEAD/file/MyProj/file.txt

  
Example Response
HTTP/1.1 200 OK
 Content-Type: text/plain
 Content-Length: 22

This is the content.
Detailed Explanation
TBD.


Committing 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 /git/commit/file/MyProj/

{
"Message" : "<Your commit message>" 
}  
Example Response
HTTP/1.1 200 OK
 Content-Type: text/plain
 Content-Length: 22

<nothing>
Detailed Explanation
TBD.


Amending a commit

Overview
To amend the last commit. Send a POST request to the git commit location.
HTTP Method
POST
Example Request
POST /git/commit/file/MyProj/

{
"Message" : "<Your commit message>",
"Amend" : "true"
}  
Example Response
HTTP/1.1 200 OK
 Content-Type: text/plain
 Content-Length: 22

<nothing>
Detailed Explanation
TBD.


This operation is not yet supported, see bug 339242.


/git/diff/

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 /git/diff/Default/file/MyProj/

  
Example Response
HTTP/1.1 200 OK
 Content-Type: text/plain
 Content-Length: 22

TBD
Detailed Explanation
TBD.


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 /git/diff/Cached/file/MyProj/

  
Example Response
HTTP/1.1 200 OK
 Content-Type: text/plain
 Content-Length: 22

TBD
Detailed Explanation
TBD.


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 /git/diff/{old revision}/file/MyProj/file.txt

{
"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/MyProj/file.txt

<nothing>
Detailed Explanation
TBD.


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 /git/diff/{old revision}..{new revision}/file/MyProj/

  
Example Response
HTTP/1.1 200 OK
 Content-Type: text/plain
 Content-Length: 22

TBD
Detailed Explanation
TBD.


/git/config/

Configuring git

Progress is being tracked on bug 337820.

/git/index/

Getting a 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 /git/index/file/MyProj/file.txt

  
Example Response
HTTP/1.1 200 OK
 Content-Type: text/plain
 Content-Length: 22

This is the content from index.
Detailed Explanation
TBD.


Staging files

Overview
To stage a file, add it to index. Send a PUT request to the git index location.
HTTP Method
PUT
Example Request
PUT /git/index/file/MyProj/file.txt

  
Example Response
HTTP/1.1 200 OK
 Content-Type: text/plain
 Content-Length: 22

<nothing>
Detailed Explanation
TBD.


Unstaging files

Overview
To unstage a file, reset index and/or working tree. Send a POST request to the git index location.
HTTP Method
POST
Example Request
POST /git/index/file/MyProj/file.txt

{
"Reset" : "MIXED" 
}  
Example Response
HTTP/1.1 200 OK
 Content-Type: text/plain
 Content-Length: 22

<nothing>
Detailed Explanation
TBD.


Progress is being tracked on bug 338202.


Progress is being tracked on bug 337212.

/git/status/

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 /git/status/file/A/folder/

  
Example Response
HTTP/1.1 200 OK
 Content-Type: application/json; charset=UTF-8
 Content-Length: 468

{
 "Added": [],
 "Changed": [],
 "Missing": [],
 "Modified": [{
   "Git": {
     "CommitLocation": "http://localhost:8080/git/commit/HEAD/file/A/file.txt",
     "DiffLocation": "http://localhost:8080/git/diff/Default/file/A/file.txt",
     "IndexLocation": "http://localhost:8080/git/index/file/A/file.txt"
   },
   "Location": "http://localhost:8080/file/A/file.txt",
   "Name": "file.txt",
   "Path": "../file.txt"
 }],
 "Removed": [],
 "Untracked": [],
 "IndexLocation" : "http://localhost:8080/git/index/file/A/",
 "CommitLocation" : "http://localhost:8080/git/commit/HEAD/file/A/"
 }
Detailed Explanation
"IndexLocation" can be used to add all files to index, "CommitLocation" can be used to commit all files.


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.DiffLocation URI Location of Git Diff resource
Git.StatusLocation URI Location of Git Status resource
Git.IndexLocation URI Location of Git Index resource

Resource/HTTP method matrix

GET PUT POST DELETE
commit #git log  ? #git commit, #git merge (#git pull) git rm
index #Getting a file content from index #git add #git reset  ?
clone list clones, get clone info  ? create clone delete clone
config #git config get #git config set #git config update #git config unset
branch #git branch #git branch #git branch #git branch
tag #git tag #git tag #git tag #git tag
remote #git remote #git remote #git remote, fetch, push remove remote
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  ? prepare git diff location  ?
status #Getting status for a git project  ?  ?  ?

Back to the top