Git Product home page Git Product logo

gitagent's Introduction

GitAgent

A web server receive HTTP request to pull local repository

中文文档

Desc

GitAgent run as a webserver. It receive command from http requests and do operation to local git repositorys.

So GitAgent let you can do git operation over http request.

With GitAgent, you can a git repository on other machine to:

  • get current status
  • pull latest code
  • checkout branch ...

GitAgent also support execute some commant after pull success, and use a password to protect http request.

install

python3 -m pip install gitagent

require

GitAgent based on python3, and those libs was required.

  • Tornado
  • GitPython
  • ws4py

if you use pip install GitAgent, the requirements will be install automatic.

config

Basic config format

The basic format of config.json is like this.

example_config = {
    "bind_ip":"0.0.0.0",
    "port":10000,
    "repo":{
        "self":{
            "repo_path":"./",
        }
    },
}

If need, you can put more than one repon into it.

full config format

if you need use password, or execute command after pull, you can add some args to config file like that.

example_config_full = {
    "bind_ip":"0.0.0.0",
    "port":10000,
    "repo":{
        "self":{
            "repo_path":"./",
            "command":{
                "cmd1":"the command 1",
                "cmd2":"the command 2",
            }
        }
    },
    "password":"123456"
}

Usage

step 1: Write default config file

python3 -m gitagent [-c config.json] write

The default config file will by written to config.json, then you can known the config format.

if the -c arg don't gived, gitagent will write the config.json to current directory

step 2: Edit the config.json

Just edit the config file as you need

step 3: Run gitagent

python3 -m gitagent [-c config.json] run

If you havn't see any error message, the gitagent is running.

API

list all repos

curl -v 'http://localhost:10000/repo'

Return:

[
    "demo1",
    "demo2",
    "demo3"
]

repo status

curl -v 'http://localhost:10000/repo/demo1'

Return:

{
    {
    "author": "AlexaZhou",
    "busy": false,
    "changed_files": {
        "A": [],
        "D": [],
        "M": [
            "agent.py"
        ],
        "R": []
    },
    "dirty": true,
    "hash": "c8c082d898c2dc18adb8e79f8992c074fb2294ce",
    "message": "some message text",
    "untracked_files": [
        "config.json"
    ]
}

busy means the repo is processing a pull request or other action

repo pull / switch branch / switch hash

curl -v -d 'git_branch=master&git_hash=abcdefg&command=cmd1&block=1' 'http://localhost:10000/repo/demo1/pull'

Return:

{
    "ret": "success"
}

args:

  • git_branch: the branch you want to checkout.
  • git_hash: is a optional arg. if git_hash not given, gitagent will checkout lastest commit on the target branch
  • command: is a optional arg. if command was gived, it will be execute after pull.
  • block: can be 0/1, if block = 1, the request will block until the git work finish

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.