Introduction

Git endpoints take advantage of all git commands known and needed to create versions of files.

Endpoints

URL [method]DescriptionInput exampleOutput example
/rest/git/getstatus [GET]get all files that have been modified or untracked(no input required){
   "timestamp": 1620216790744,
   "status": "200",
   "data": [
        {
           "fileName": "FileToF.txt",
           "status": "Untracked"
        },
        {
           "fileName": "newfile.txt",
           "status": "Modified"
        }
    ]
}
/rest/git/history [GET]get all commits history, with their IDs ,authors ,messages, dates and if considired as current version or not (no input required){
   "timestamp": 1620217014704,
   "status": "200",
   "data": [
        {
           "date": "Tue May 04 16:37:49 GMT+01:00 2021",
           "current": "true",
           "author": "person1232",
           "id": "11e8707eb50e25c00a62e4efedb5f6071ec7e27e",
           "message": "version 2"
        },
        {
           "date": "Tue May 04 13:28:12 GMT+01:00 2021",
           "current": "false",
           "author": "person1",
           "id": "4b64d02451f47d9cb91d08faa986c941deef0f5c",
           "message": "version 1"
        }
    ]
}
/rest/git/commit [POST]commit changes in files with a message{
"files":
[
{"fileName" : "newFile.xml"},
{"fileName" : "/dir/modifiedFile.pdf"}
],
"message": "this is a commit message"
}

it returns a String with the commit message meaning that the commit has passed successfully.

eg :

{
   "timestamp": 1620217700570,
   "status": "200",
   "data": "this is a commit message"
}
  

/rest/git/switchComit/{id}

[GET]

switch to a certain version and return the history of all commits.

NB : if there are some modified files in the current version, these files will be moved to a new directory called :

.../archive/git-{timestamp}

the {id} in the URL should be replaced by the id of the wanted commit.

eg : 

rest/git/switchComit/4b64d02451f47d9cb91d08faa986c941deef0f5c

 

{
   "timestamp": 1620217014704,
   "status": "200",
   "data": [
        {
           "date": "Tue May 04 16:37:49 GMT+01:00 2021",
           "current": "false",
           "author": "person1232",
           "id": "11e8707eb50e25c00a62e4efedb5f6071ec7e27e",
           "message": "version 2"
        },
        {
           "date": "Tue May 04 13:28:12 GMT+01:00 2021",
           "current": "true",
           "author": "person1",
           "id": "4b64d02451f47d9cb91d08faa986c941deef0f5c",
           "message": "version 1"
        }
    ]
}
/rest/git/update [GET]

Integrates and pulls changes from a remote repository into the current branch.

(no input required)

it returns a success message.

eg : 

{
   "timestamp": 1620219625637,
   "status": "200",
   "data": "branch is now updated"
}
/rest/environment/init [POST]

Clone a git repository into the directory of the current environment,

if it doesn't exist it creates a new directory and initialize the repo,

if the directory exists, the endpoint renames the directory and creates a new one and clones the repository.

(no input required)

it returns a "success" message :

eg :

{
   "timestamp": 1620229625932,
   "status": "200",
   "data": "Repository initialized successfully !"
}
/rest/git/checkout/{branch} [POST]switch to a certain branch

the {branch} must be replaced by the name of the branch destination.

eg : /rest/git/checkout/master

    /rest/git/checkout/develop

it returns a "success" message of checkout branch.

eg :

{
   "timestamp": 1620229625932,
   "status": "200",
   "data": "switched to branch : master"
}

/rest/git/newbranch/{branch}

[POST]

create and switch to a new branch 

the {branch} must be replaced by the name of the branch destination.

eg :

    /rest/git/checkout/newBranch

it returns a "success" message of the branch creation.

eg :

{
   "timestamp": 1620229625932,
   "status": "200",
   "data": "new branch has been created : newBranch"
}
/rest/git/revert [POST]switch the modified file to the initial head version. {
"files":
[
{"fileName" : "newFile.xml"},
{"fileName" : "/dir/modifiedFile.pdf"}
]
}

it returns a "success" message.

eg :

{
   "timestamp": 1620229625932,
   "status": "200",
   "data": "the selected files has been synchronized to HEAD successfully !"
}

Errors

below, you can find an example of technical and functional errors :

{
   "timestamp": 1620221672951,
   "status": "500",
   "error": "JSON file is not valid",
   "thechnicalError": "JSONObject[\"fileName\"] not found."
}

the functional error is shown with the JSON key "error", while technical error is stored in the "thechnicalError" key.

Tags:
    
This wiki is hosted and managed by iXPath
Powered by XWiki 13.3 debian