From c8f820e238af41b3c6514109872e38dd03e9d3ee Mon Sep 17 00:00:00 2001 From: Pakin Date: Fri, 15 May 2026 14:27:18 +0700 Subject: [PATCH] add usages Signed-off-by: Pakin --- README.md | 171 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..2e0bce6 --- /dev/null +++ b/README.md @@ -0,0 +1,171 @@ +# 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= +``` + +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 + + + "Enable" + 1080 + 1920 +; "0xeae6e1" + SoundVolume + + ; 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 +... +``` + +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...