3da / MercurialHttpHooks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MercurialHttpHooks

Install

  1. Install library 'requests' (pip install requests)
  2. Copy HttpHooks.py to your python lib directory. For example: C:\Python27\Lib\site-packages\hgext
  3. Add pretxnchangegroup or different hook to your hgrc file and specify API url as described below.

Exmple config

Add to your .hg\hgrc file

[hooks]
pretxnchangegroup.HttpHooks = python:hgext.HttpHooks.hook
incoming.HttpHooks = python:hgext.HttpHooks.hook
txnclose.HttpHooks = python:hgext.HttpHooks.hook

[httphooks]
url = http://localhost:36884/api/

Alternatively you can write full path for script: python:/.../HttpHooks.py:hook

Tested work with following hooks:

  • pretxnchangegroup
  • incoming
  • txnclose
  • tag
  • preoutgoing

Example request sent by hook

{
  "UserName": "IUSR",
  "Commits": [
    {
      "Message": "Performance improvements",
      "Rev": 790,
      "Tags": [
        "tip"
      ],
      "Hex": "c3ae4169983c55cc46b2ce06655d056fc82201e8",
      "User": "John Doe",
      "MercurialDate": [
        1540059873.0,
        -10800.0
      ],
      "Branch": "Release",
      "Parents": [
        {
          "Message": "Small fix",
          "Rev": 789,
          "Tags": [],
          "Hex": "cb5c943930314b3e2bb70c96efe5a350a51214d9",
          "User": "John Doe",
          "MercurialDate": [
            1540058889.0,
            -10800.0
          ],
          "Branch": "default",
          "Parents": null,
          "Files": [
            "src/Main.c"
          ]
        }
      ],
      "Files": [
        "src/HelloWorld.cs"
      ]
    }
  ]
}

Example response should be sent to hook

{
  "Success": false,
  "Message": "Wrong commit name. Please write ticket number"
}

About

License:MIT License


Languages

Language:Python 100.0%