tbm-git-repo-service/README.md
Pakin b70a35135c update usage of commit
Signed-off-by: Pakin <pakin.t@forth.co.th>
2026-05-15 14:38:27 +07:00

183 lines
2.3 KiB
Markdown

# tbm-git-service
Git repo as a service with operational endpoints
---
## Endpoints
### Checkout file
Get file content or list of file in directory from HEAD
```
GET .../checkout?path=<path_to_file>
```
Examples
Get list of files in directory
```bash
curl -X GET http://localhost:36593/checkout\?path\=inter
aus,common,dev,gbr,gbr_premium,hkg,ltu,mys,rou,sgp,tha,tha_premium,uae_dubai,usa,whatthecup
```
Get file
```bash
curl -X GET http://localhost:36593/checkout\?path\=inter/mys/xml/page_catalog_group_other.lxml
<Popup>
<Cache> "Enable" </Cache>
<Width> 1080 </Width>
<Height> 1920 </Height>
;<Background> "0xeae6e1" </Background>
<Volume> SoundVolume </Volume>
<EventOpen>
; On open
```
Error
```bash
curl -X GET http://localhost:36593/checkout\?path\=inter2
File not found
```
---
### Fetch
Fetching & update index of current repo
```
GET .../fetch
```
Expected result
```
{"result": "fetch success"}
```
Error
```
{"error": "..."}
```
---
### Commit
Commit changes of file i.e. editing, adding, etc.
```
POST .../commit
```
Body must be multipart
- Single file
```
path: string
file: text/binary is acceptable
signature_username: string
signature_email: stirng
message: string
```
- Multiple file
```
signature_username: string
signature_email: stirng
message: string
fileX1: text/binary is acceptable
pathX1: string
fileX2: text/binary is acceptable
pathX2: string
...
```
Expected result
```
{"result": "commit hash id"}
```
Error
```
{"error": "..."}
```
Example
```curl
curl --request POST \
--url http://localhost:36583/commit \
--header 'content-type: multipart/form-data' \
--form path=mys/version.dev \
--form 'signature_username=git api' \
--form signature_email=supra.m2.dev@forth.co.th \
--form 'message=test commit' \
--form file=@./mys.version.test
```
NOTE: file & path in multiple file must have the same name after
---
### Push
Push local commits to remote
```
GET .../push
```
Expected result
```
{"result": "push completed"}
```
Error
```
{"error": "..."}
```
---
### Pull
Pull commits from remote. This operation always does git reset hard first before pull for reason of no conflicts.
```
GET .../pull
```
Expected result
```
{"result": "pull completed"}
```
Error
```
{"error": "..."}
```
NOTE: Commit did lost but could be checkout later
---
### Recovery
WIP...