TraHub models

Models and utilities used to save commits sent to your project repository (and its clones) and reported to trac.

class trac_hub.model.GitHubCommit(env, git_url=None, id=None, url=None, time=None, author=None, message=None, **kw)
Parameter:author – dict containing the name and email of the commit author
env
Trac environment object (trac.env:Environment).
git_url
Url of the main GitHub repository.
id
Commit id (hash key).
url
Commit’s GitHub url.
time
Commit push time (more exactly, when Trac have been notified of the commit)
message
Commit message
author
Return type:Boolean. True if it is a commit to a clone repository.
classmethod create_from_json(env, json, git_url='', db=None)

Save commit from GitHub json payload.

Raise an exception if json if not valid json string, or if it could not save a commit.

Note: it doesn’t roll back partial payload saved.

classmethod get_commit_by_date(env, start, stop, git_url=None)

Get the commits on a specific range of date.

Parameters:
  • env – Trac environment
  • start – time stamp
  • stop – time stamp
Git_url:

url of the main repository.

Return type:

list (generator) of commit

get_original_commit()

Return the first same exact commit.

Two commits are equals if the have the same id and identical if they have the same url. I assume a commit merged in an other repository will have the same id or hash key; id, is miss leading.

Raise a GitHubCommitNoRecord exception if it is the first commit to be reported.

is_clone()
Test if the commit comes from the main repository or a clone.
parse_message()

Parse the commit message ticket action.

Accept to type of action: Ref and fixed. To reference a ticket use “issue 1” or “#1”. You can reference more than one ticket, like “Ref: #1, #2 and &3”.

Reference to ticket should be on the first line.

Return type:a list (generator) of ‘(action, ticket id)’ tuple.
save(db=None)
Save the commit.
exception trac_hub.model.GitHubCommitException
Generic exception
exception trac_hub.model.GitHubCommitNoRecord
Raise when a commit cannot be found

Previous topic

TracHub design

This Page