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

Bug 338203

Summary: [server] Provide REST API for git commit
Product: [ECD] Orion Reporter: Tomasz Zarna <tomasz.zarna>
Component: ClientAssignee: Tomasz Zarna <tomasz.zarna>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: libingw, Szymon.Brandys
Version: 0.2   
Target Milestone: 0.2   
Hardware: PC   
OS: All   
Whiteboard:
Bug Depends on: 338200, 339088    
Bug Blocks: 336116    

Description Tomasz Zarna CLA 2011-02-25 06:48:11 EST
We're going to need REST API for git commit (passing a commit message, and a boolean for "amend" or not).
Comment 1 Tomasz Zarna CLA 2011-03-04 08:50:05 EST
Partially fixed with 7cd152c9c693e5993ad02275ca3d1c0168d0dace. 

To commit all staged files, do POST on /git/commit/file/{projectId} passing {"Message"[1]:<commit message>} in body. "Amend"[2] param is not yet supported, neither is committing a single file. I'm not able to specify these using CommitCommand[3]. I'll try to work around that limitation. 

To get a file content from HEAD, call GET on /git/commit/HEAD/file/{path}. For now only "HEAD" ref is accepted, but this could be extended in the future.

[1] org.eclipse.orion.server.git.GitConstants.KEY_COMMIT_MESSAGE
[2] org.eclipse.orion.server.git.GitConstants.KEY_COMMIT_AMEND
[3] org.eclipse.jgit.api.CommitCommand
Comment 2 Tomasz Zarna CLA 2011-03-07 09:24:04 EST
(In reply to comment #1)
> "Amend"[2] param is not yet supported,

See bug 339088.

> neither is committing a single file.

See http://egit.eclipse.org/r/#change,2635.
Comment 3 Tomasz Zarna CLA 2011-03-07 11:41:52 EST
Amending can be achieved by doing POST on /git/commit/file/{projectId} and passing an extra parameter in request body: {..., "Amend":"true"}. When omitted or set to "false" a regular commit is made.

So, the last missing bit here is being able to commit a single file (provide a path to commit). I'm keeping my fingers crossed for http://egit.eclipse.org/r/#change,2635, which should be helpful here.
Comment 4 Tomasz Zarna CLA 2011-03-08 05:07:41 EST
(In reply to comment #3)
> So, the last missing bit here is being able to commit a single file (provide a
> path to commit).

The last missing part has been moved to bug 339190. Marking as fixed.