IGitt.Interfaces package¶
Submodules¶
IGitt.Interfaces.Actions module¶
This module contains the Actions classes representing the actions which could be taken on webhooks.
-
class
IGitt.Interfaces.Actions.
InstallationActions
[source]¶ Bases:
enum.Enum
Installation and Integration related actions.
-
CREATED
= 1¶
-
DELETED
= 2¶
-
REPOSITORIES_ADDED
= 3¶
-
REPOSITORIES_REMOVED
= 4¶
-
-
class
IGitt.Interfaces.Actions.
IssueActions
[source]¶ Bases:
enum.Enum
Issue related reactions.
-
ASSIGNEES_CHANGED
= 8¶
-
ATTRIBUTES_CHANGED
= 5¶
-
CLOSED
= 2¶
-
COMMENTED
= 4¶
-
LABELED
= 6¶
-
OPENED
= 1¶
-
REOPENED
= 3¶
-
UNLABELED
= 7¶
-
WEIGHT_CHANGED
= 9¶
-
IGitt.Interfaces.Comment module¶
This module contains the Comment class representing a comment on a pull request, commit or issue.
-
class
IGitt.Interfaces.Comment.
Comment
[source]¶ Bases:
IGitt.Interfaces.IGittObject
A comment, essentially represented by body and author.
Retrieves the author of the comment wrapped in a User object.
-
body
¶ Retrieves the body of the comment.
-
created
¶ Retrieves a timestamp on when the comment was created.
-
delete
()[source]¶ Deletes this comment at the hosting site.
Raises: RuntimeError – If the hosting service doesn’t support deletion.
-
number
¶ Retrieves the id of the comment.
-
repository
¶ Retrieves the repository in which the comment was posted.
-
type
¶ Retrieves the type of the comment.
-
updated
¶ Retrieves a timestamp on when the comment was updated the last time.
IGitt.Interfaces.Commit module¶
This module contains the actual commit object.
-
class
IGitt.Interfaces.Commit.
Commit
[source]¶ Bases:
IGitt.Interfaces.IGittObject
An abstraction representing a commit. This especially exposes functions to place comments and manipulate the status.
-
ack
()[source]¶ Acknowledges the commit by setting the manual review GitMate status to success.
>>> CommitMock = type('CommitMock', (Commit,), ... {'set_status': lambda self, s: print(s.status)}) >>> CommitMock().ack() Status.SUCCESS
Raises: RuntimeError – If something goes wrong (network, auth…).
-
closes_issues
¶ Returns a set of Issue objects which would be closed upon merging this commit.
-
combined_status
¶ Retrieves a combined status of all the commits.
Returns: Status.FAILED if any of the commits report as error or failure or canceled Status.PENDING if there are no statuses or a commit is pending or a test is running Status.SUCCESS if the latest status for all commits is success
-
comment
(message: str, file: Optional[str] = None, line: Optional[int] = None, mr_number: Optional[int] = None) → <module 'IGitt.Interfaces.Comment' from '/opt/build/repo/IGitt/Interfaces/Comment.py'>[source]¶ Puts a comment on the new version of the given line. If the file or line is None, the comment will be placed at the bottom of the commit.
Parameters: - message – The message to comment.
- file – Filename or None
- line – Line number or None
- mr_number – The number of a merge request if this should end up in the review UI of the merge request.
Raises: RuntimeError – If something goes wrong (network, auth…).
-
get_keywords_issues
(keyword: str, body_list: List) → Set[int][source]¶ Returns a set of tuples(issue number, name of the repository the issue is contained in), which are mentioned with given
keyword
.
-
get_statuses
() → Set[IGitt.Interfaces.CommitStatus.CommitStatus][source]¶ Retrieves the all commit statuses.
Returns: A (frozen)set of CommitStatus objects. Raises: RuntimeError – If something goes wrong (network, auth…).
-
mentioned_issues
¶ Returns a set of Issue objects which are related to the commit.
-
message
¶ Retrieves the commit message.
Returns: Commit message as string.
-
parent
¶ Retrieves the parent commit if possible.
Returns: A Commit object.
-
pending
()[source]¶ Sets the commit to a pending manual review state if there is no manual review state yet.
Given a commit with an unrelated status:
>>> CommitMock = type( ... 'CommitMock', (Commit,), ... {'set_status': lambda self, s: self.statuses.append(s), ... 'get_statuses': lambda self: self.statuses, ... 'statuses': []}) >>> commit = CommitMock() >>> commit.set_status(CommitStatus(Status.FAILED, context='unrelated')) >>> len(commit.get_statuses()) 1
The invocation of pending will now add a pending status:
>>> commit.pending() >>> len(commit.get_statuses()) 2 >>> commit.get_statuses()[1].context 'review/gitmate/manual'
However, if there is already a manual review state, the invocation of pending won’t affect the status:
>>> commit.get_statuses().clear() >>> commit.ack() >>> commit.pending() # Won't do anything >>> len(commit.get_statuses()) 1 >>> commit.get_statuses()[0].status <Status.SUCCESS: 1>
Raises: RuntimeError – If something goes wrong (network, auth…).
-
repository
¶ Retrieves the repository that holds this commit.
Returns: A Repository object.
-
set_status
(status: IGitt.Interfaces.CommitStatus.CommitStatus)[source]¶ Adds the given status to the commit. If a status with the same context already exists, it will be bluntly overridden.
Parameters: status – The CommitStatus to set to this commit. Raises: RuntimeError – If something goes wrong (network, auth…).
-
sha
¶ Retrieves the sha of the commit.
Returns: A string holding the SHA of the commit.
-
unack
()[source]¶ Unacknowledges the commit by setting the manual review GitMate status to failed.
>>> CommitMock = type('CommitMock', (Commit,), ... {'set_status': lambda self, s: print(s.status)}) >>> CommitMock().unack() Status.FAILED
Raises: RuntimeError – If something goes wrong (network, auth…).
-
unified_diff
¶ Retrieves the unified diff for the commit excluding the diff index.
-
will_close_issues
¶ Returns a set of Issue objects which would be closed as stated in this commit message.
-
will_fix_issues
¶ Returns a set of Issue objects which would be fixed as stated in this commit message.
-
will_resolve_issues
¶ Returns a set of Issue objects which would be resolved as stated in this commit message.
-
IGitt.Interfaces.CommitStatus module¶
This module contains the CommitStatus class as well as the actual Status class.
IGitt.Interfaces.Content module¶
This module contains the Content class.
-
class
IGitt.Interfaces.Content.
Content
[source]¶ Bases:
IGitt.Interfaces.IGittObject
Represents content on GitHub or GitLab or a bug report on bugzilla or so.
IGitt.Interfaces.Hoster module¶
Contains the git Hoster abstraction.
-
class
IGitt.Interfaces.Hoster.
Hoster
[source]¶ Bases:
IGitt.Interfaces.IGittObject
Abstracts a service like GitHub and allows e.g. to query for available repositories and stuff like that.
-
get_user
(username: str = None) → IGitt.Interfaces.User.User[source]¶ Retrieves repository name from given webhook data.
Parameters: username – Username to fetch, use None to fetch authenticated user. Returns: The user.
-
handle_webhook
(event: str, data: dict)[source]¶ Handles a webhook for you.
If it’s an issue event it returns e.g.
IssueActions.OPENED, [Issue(...)]
, for comments it returnsMergeRequestActions.COMMENTED, [MergeRequest(...), Comment(...)]
.Parameters: - event – The HTTP_X_GITLAB_EVENT of the request header.
- data – The pythonified JSON data of the request.
Returns: An IssueActions or MergeRequestActions member and a list of the affected IGitt objects.
-
master_repositories
¶ Retrieves the repositories the user has administrative access to.
-
owned_repositories
¶ Retrieves the full names of the owned repositories as strings.
Returns: A set of strings.
-
static
raw_search
(token: IGitt.Interfaces.Token, raw_query: str) → Iterator[IGitt.Interfaces.Issue.Issue][source]¶ Search issues using the raw_query string.
Parameters: - token – Token object.
- raw_query – Raw query string.
Returns: An iterator to iterator over the search results.
-
write_repositories
¶ Retrieves the full names of repositories this user can write to.
Returns: A set of strings.
-
IGitt.Interfaces.Installation module¶
This module contains the Installation abstraction class which provides properties and actions related to integration installations on supported providers.
-
class
IGitt.Interfaces.Installation.
Installation
[source]¶ Bases:
IGitt.Interfaces.IGittObject
Represents an application Installation on supported providers.
-
app_id
¶ The application which was installed.
-
identifier
¶ Returns the identifier of the installation.
-
permissions
¶ The permissions granted to this installation.
-
repositories
¶ Returns the set of repositories this installation has access to.
-
webhooks
¶ Returns the list of webhooks registered by installing the application.
-
IGitt.Interfaces.Issue module¶
This module contains the Issue abstraction class which provides properties and actions related to issues and bug reports.
-
class
IGitt.Interfaces.Issue.
Issue
[source]¶ Bases:
IGitt.Interfaces.IGittObject
Represents an issue on GitHub or GitLab or a bug report on bugzilla or so.
-
add_comment
(body) → IGitt.Interfaces.Comment.Comment[source]¶ Adds a comment to the issue.
Parameters: body – The content of the comment. Returns: The newly created comment. Raises: RuntimeError – If something goes wrong (network, auth…).
-
add_to_total_time_spent
(relative_time_spent: datetime.timedelta)[source]¶ Adds the value of relative_time_spent to total_time_spent. Allows for positive and negative values. Allows any time unit of the timedelta object. Does nothing when passing None or 0.
-
assignees
¶ Retrieves a set of usernames of assignees.
Retrieves the author of the comment wrapped in a User object.
-
available_assignees
¶ Compiles a set of Users that are available for assigning this issue.
Returns: A set of User objects.
-
available_labels
¶ Compiles a set of labels that are available for labelling this issue.
Returns: A set of label captions.
-
comments
¶ Retrieves a list of comments which are on the issue excliding the description.
Returns: A list of Comment objects.
-
static
create
(token, repository, title, body='', issue_type=None)[source]¶ Create a new issue in repository.
-
created
¶ Retrieves a timestamp on when the comment was created.
-
delete
()[source]¶ Deletes the issue.
Raises: RuntimeError – If something goes wrong (network, auth…).
-
description
¶ Retrieves the main description of the issue.
-
labels
¶ Retrieves the set of labels the issue is currently tagged with.
Returns: The set of labels.
-
milestone
¶ Retrieves the milestone.
-
mrs_closed_by
¶ Returns the merge requests that close this issue.
-
number
¶ Returns the issue “number” or id.
-
reactions
¶ Retrieves the reactions / award emojis applied on the issue.
-
reopen
()[source]¶ Reopens the issue.
Raises: RuntimeError – If something goes wrong (network, auth…).
-
repository
¶ Returns the repository this issue is linked with.
-
state
¶ Get’s the state of the issue.
Returns: Either ‘open’ or ‘closed’.
-
time_estimate
¶ Retrieves the time_estimate in seconds. Writes the time_estimate into the seconds property of an timedelta object.
-
title
¶ Retrieves the title of the issue.
-
total_time_spent
¶ Retrieves the total_time_spent in seconds. Writes the total_time_spent into the seconds property of an timedelta object.
-
updated
¶ Retrieves a timestamp on when the comment was updated the last time.
-
weight
¶ Retrieves the weight associated with the current issue.
-
IGitt.Interfaces.MergeRequest module¶
Contains a class that represents a request to merge something into some git branch.
-
class
IGitt.Interfaces.MergeRequest.
MergeRequest
[source]¶ Bases:
IGitt.Interfaces.Issue.Issue
A request to merge something into the main codebase. Can be a patch in a mail or a pull request on GitHub.
-
affected_files
¶ Retrieves the affected files.
Returns: A set of filenames relative to repo root.
Returns the author of the MR wrapped in a User object.
-
base
¶ Retrieves the base commit of the merge request, i.e. the one it should be merged into.
Returns: A Commit object.
-
base_branch_name
¶ Retrieves the base branch name of the merge request, i.e. the one it should be merged into.
Returns: A string.
-
close
()[source]¶ Closes the merge request.
Raises: RuntimeError – If something goes wrong (network, auth…).
-
closes_issues
¶ Returns a set of Issue objects which would be closed upon merging this pull request.
-
commits
¶ Retrieves all commits that are contained in this request.
Returns: A list of Commits.
-
created
¶ Retrieves a timestamp on when the merge request was created.
-
diffstat
¶ Gets additions and deletions of a merge request.
Returns: An (additions, deletions) tuple.
-
head
¶ Retrieves the head commit of the merge request, i.e. the one which would be merged.
Returns: A Commit object.
-
head_branch_name
¶ Retrieves the head branch name of the merge request, i.e. the one that will be merged.
Returns: A string.
-
mentioned_issues
¶ Returns a set of Issue objects which are related to the pull request.
-
merge
(message: str = None, sha: str = None, should_remove_source_branch: bool = False, _github_merge_method: str = None, _gitlab_merge_when_pipeline_succeeds: bool = False)[source]¶ Merges the merge request.
Parameters: - message – The commit message.
- sha – The commit sha that the HEAD must match in order to merge.
- should_remove_source_branch – Whether the source branch should be removed upon a successful merge.
- _github_merge_method – On GitHub, the merge method to use when merging the MR. Can be one of merge, squash or rebase.
- _gitlab_wait_for_pipeline – On GitLab, whether the MR should be merged immediately after the pipeline succeeds.
Raises: - RuntimeError – If something goes wrong (network, auth…).
- NotImplementedError – If an unused parameter is passed.
-
mergeable
¶ Returns true if there is no merge conflict.
-
milestone
¶ Retrieves the milestone.
-
number
¶ Returns the MR “number” or id.
-
reopen
()[source]¶ Reopens the merge request.
Raises: RuntimeError – If something goes wrong (network, auth…).
-
repository
¶ Retrieves the repository where this PR is opened at.
Returns: A Repository object.
-
source_repository
¶ Retrieves the repository where this PR’s head branch is located at.
Returns: A Repository object.
-
state
¶ Get’s the state of the merge request.
Returns: A MergeRequestStates object indicating current state.
-
target_repository
¶ Retrieves the repository where this PR is opened at. An alias to
self.repository
property.Returns: A Repository object.
-
tests_passed
¶ Returns True if all commits of the merge request have a success state. If you wish to only get the head state, use mr.head.combined_status.
-
updated
¶ Retrieves a timestamp on when the merge request was updated the last time.
-
IGitt.Interfaces.Milestone module¶
This module contains the milestone abstraction class which provides properties and actions related to milestones.
-
class
IGitt.Interfaces.Milestone.
Milestone
[source]¶ Bases:
IGitt.Interfaces.IGittObject
Represents a milestone for GitHub or GitLab or any similar collection of issues.
-
close
()[source]¶ Closes the milestone.
Raises: RuntimeError – If something goes wrong (network, auth…).
-
created
¶ Retrieves a timestamp on when the milestone was created.
-
delete
()[source]¶ Deletes the milestone. This is not possible with GitLab api v4.
Raises: RuntimeError – If something goes wrong (network, auth…).
-
description
¶ Retrieves the main description of the milestone.
-
due_date
¶ Retrieves a timestamp on when the milestone is due.
-
issues
¶ Retrieves a set of issue objects that are assigned to this milestone.
-
merge_requests
¶ Retrieves a set of merge request objects that are assigned to this milestone.
-
number
¶ Returns the milestone “number” or id.
-
project
¶ Returns the repository this milestone is linked with.
-
reopen
()[source]¶ Reopens the milestone.
Raises: RuntimeError – If something goes wrong (network, auth…).
-
start_date
¶ Retrieves a timestamp on when the milestone was started.
-
state
¶ Get’s the state of the milestone.
Returns: Either MilestoneStates.OPEN or MilestoneStates.CLOSED.
-
title
¶ Retrieves the title of the milestone.
-
updated
¶ Retrieves a timestamp on when the milestone was updated the last time.
-
IGitt.Interfaces.Notification module¶
Contains the Notification base class.
-
class
IGitt.Interfaces.Notification.
Notification
[source]¶ Bases:
IGitt.Interfaces.IGittObject
Represents a notification/todo on GitHub or GitLab.
-
static
fetch_all
(token: IGitt.Interfaces.Token)[source]¶ Returns the list of notifications for the user bearing the token.
-
identifier
¶ Returns the id of the notification.
-
pending
¶ Returns True if the notification is pending/not read.
-
reason
¶ Returns the reason for notification.
-
repository
¶ Returns the repository this notification is related to.
-
subject
¶ Returns the subject of notification.
-
subject_type
¶ Returns the type of the subject of the notification.
-
static
-
class
IGitt.Interfaces.Notification.
Reason
[source]¶ Bases:
enum.Enum
The enum representing the reason/action of a notification.
-
APPROVAL_REQUIRED
= 'approval_required'¶
-
ASSIGNED
= 'assigned'¶
-
AUTHORED
= 'authored'¶
-
BUILD_FAILED
= 'build_failed'¶
-
COMMENTED
= 'commented'¶
-
INVITED
= 'invited'¶
-
MANUAL
= 'manual'¶
-
MARKED
= 'marked'¶
-
MENTIONED
= 'mentioned'¶
-
STATE_CHANGED
= 'state_changed'¶
-
SUBSCRIBED
= 'subscribed'¶
-
IGitt.Interfaces.Organization module¶
This module contains the Issue abstraction class which provides properties and actions related to issues and bug reports.
-
class
IGitt.Interfaces.Organization.
Organization
[source]¶ Bases:
IGitt.Interfaces.IGittObject
Represents an organization on GitHub or GitLab.
-
billable_users
¶ Number of paying/registered users on the organization.
-
static
create
(token: IGitt.Interfaces.Token, name: str, path: str, parent_id: Optional[int] = None, description: Optional[str] = None, visibility: str = 'private', lfs_enabled: bool = False, request_access_enabled: bool = False)[source]¶ Creates a new organization from the given parameters.
Parameters: - token – The credentials to be used for authorization.
- name – The name of the organization.
- path – The path of the organization.
- parent_id – The parent organization id to create nested organization.
- description – The description of the organization.
- visibility – Controls the visibility of the organization. Can be either ‘private’, ‘public’ or ‘internal’.
- lfs_enabled – Enables Git Large File System for projects in this organization.
- request_access_enabled – Allow users to request member access on the organization.
-
description
¶ Returns the description of the Organization.
-
filter_issues
(state: Optional[str] = 'opened', label: Optional[str] = None, assignee: Optional[str] = None) → Set[IGitt.Interfaces.Issue.Issue][source]¶ Filters the issues in the organization based on properties
Parameters: - state – ‘opened’ or ‘closed’ or ‘all’
- label – Label of the issue
- assignee – username of issue assignee
Returns: Set of Issue objects
-
identifier
¶ Returns the identifier of the organization.
-
issues
¶ Returns set of issue objects in this organization.
-
masters
¶ Returns the user handles of all users able to manage members, usually the master role (sometimes no such role exists, then same as owners).
-
name
¶ The name of the organization.
-
owners
¶ Returns the user handles of all admin users, usually the owner role.
-
repositories
¶ Returns the list of repositories contained in this organization.
-
suborgs
¶ Returns the sub-organizations within this repository.
-
IGitt.Interfaces.Reaction module¶
Holds the Reaction class representing reactions on issues, comments and merge requests.
-
class
IGitt.Interfaces.Reaction.
Reaction
[source]¶ Bases:
IGitt.Interfaces.IGittObject
Represents a reaction / award emoji on GitHub and GitLab.
-
name
¶ Returns the name of the reaction.
-
user
¶ Returns the user who reacted with this.
-
IGitt.Interfaces.Repository module¶
Contains the Repository class.
-
class
IGitt.Interfaces.Repository.
Repository
[source]¶ Bases:
IGitt.Interfaces.IGittObject
This class depicts a Repository at a hosting service like GitHub. Thus, on top of access to the actual code and history, it also provides access to issues, PRs, hooks and so on.
-
clone_url
¶ Retrieves an url that can be used for cloning the repository.
Returns: A string that can be used with git clone <url>
as url.
-
commits
¶ Retrieves the set of commits in this repository.
Returns: Set of Commit objects.
-
static
create
(token: IGitt.Interfaces.Token, name: str, path: Optional[str] = None, namespace_id: Optional[int] = None, default_branch: Optional[str] = 'master', resolve_outdated_diff_discussions: bool = False, import_url: Optional[str] = None, public_jobs: bool = False, tag_list: Optional[List[str]] = None, avatar: object = None, ci_config_path: Optional[str] = None, repository_storage: Optional[str] = None, approvals_before_merge: Optional[int] = None, org_name: Optional[str] = None, description: Optional[str] = None, homepage: Optional[str] = None, visibility: str = 'public', has_issues: bool = True, has_merge_requests: bool = True, has_jobs: bool = True, has_snippets: bool = True, has_projects: bool = True, has_wiki: bool = True, has_container_registry: bool = True, has_shared_runners: bool = True, has_lfs: bool = False, team_id: Optional[int] = None, auto_init: bool = False, gitignore_template: Optional[str] = None, license_template: Optional[str] = None, allow_request_access: bool = True, allow_squash_merge: bool = True, allow_merge_commit: bool = True, allow_rebase_merge: bool = True, allow_printing_merge_request_link: bool = True, only_allow_merge_if_pipeline_succeeds: bool = False, project_type: Optional[str] = None, project_key: Optional[str] = None, project_lead: Optional[str] = None)[source]¶ Creates a new repository and returns it.
-
create_file
(path: str, message: str, content: str, branch: Optional[str] = None, committer: Optional[str] = None, author: Optional[dict] = None, encoding: Optional[str] = None)[source]¶ Creates a new file
-
create_fork
(organization: Optional[str] = None, namespace: Optional[str] = None)[source]¶ Create a fork
-
create_label
(name: str, color: Optional[str] = None, description: Optional[str] = None, label_type: Optional[str] = None)[source]¶ Creates a new label.
Parameters: - name – The name of the label to create.
- color – A HTML color value with a leading #.
- description – The description of the label to be created.
- label_type – The type of the label to be created.
Raises: - ElementAlreadyExistsError – If the label name already exists.
- RuntimeError – If something goes wrong (network, auth…).
-
create_merge_request
(title: str, base: str, head: str, body: Optional[str] = None, target_project_id: Optional[int] = None, target_project: Optional[str] = None)[source]¶ Creates a PR
-
delete_hook
(url: str)[source]¶ Deletes all webhooks to the given URL. (Does nothing if no such hook exists.)
Parameters: url – The URL to not fire the webhook to anymore. Raises: RuntimeError – If something goes wrong (network, auth…).
-
delete_label
(name: str)[source]¶ Deletes a label.
Parameters: name – The caption of the label to delete.
Raises: - ElementDoesntExistError – If the label doesn’t exist.
- RuntimeError – If something goes wrong (network, auth…).
-
filter_commits
¶ Filter commits based on properties.
Author: Author of the commit. Returns: Set of Commit objects.
-
filter_issues
(state: str = 'opened', label: Optional[str] = None, assignee: Optional[str] = None) → set[source]¶ Filters the issues from the repository based on properties.
Parameters: - state – ‘opened’ or ‘closed’ or ‘all’.
- label – Label of the issue
- assignee – username of issue assignee
-
filter_merge_requests
(state: str = 'opened') → set[source]¶ Filters the merge requests from the repository based on the state of the merge requests.
Parameters: state – ‘merged’ or ‘opened’ or ‘closed’ or ‘all’
-
full_name
¶ Retrieves the full name of the repository, that identifies it uniquely at the hoster.
Returns: A string, e.g. ‘coala-analyzer/coala’.
-
get_clone
() → Union[git.repo.base.Repo, str][source]¶ Clones the repository into a temporary directory:
>>> test_repo = type( ... 'MockRepo', (Repository,), ... {'clone_url': 'https://github.com/sils/configurations'}) >>> repo, path = test_repo().get_clone()
With this Repo object you can easily access the source code of the repository as well as all commits:
>>> type(repo) <class 'git.repo.base.Repo'> >>> repo.branches [<git.Head "refs/heads/master">]
Or simply access it via the path if you care only for the head:
>>> from os.path import exists, join >>> assert exists(join(path, '.gitignore'))
Be sure to not forget to clean it up in the end:
>>> from shutil import rmtree >>> rmtree(path)
Returns: A tuple containing a Repo object and the path to the repository. Raises: RuntimeError – If something goes wrong (network, auth…).
-
get_issue
(issue_number: int)[source]¶ Retrieves an issue.
Parameters: issue_number – The issue ID of the issue to retrieve.
Returns: An Issue object.
Raises: - ElementDoesntExistError – If the issue doesn’t exist.
- RuntimeError – If something goes wrong (network, auth…).
-
get_labels
() → Set[str][source]¶ Retrieves the set of labels.
Returns: A set of strings, the captions of the labels. Raises: RuntimeError – If something goes wrong (network, auth…).
-
get_mr
(mr_number: int)[source]¶ Retrieves an MR.
Parameters: mr_number – The merge_request ID of the MR to retrieve. Returns: An MR object.
-
get_permission_level
(user) → IGitt.Interfaces.AccessLevel[source]¶ Retrieves the permission level for the specified user on this repository.
-
hooks
¶ Retrieves all URLs this repository is hooked to.
Returns: Set of URLs (str).
-
identifier
¶ Returns the identifier of the repository.
-
issues
¶ Retrieves a set of open issue objects.
-
merge_requests
¶ Retrieves a set of open merge request objects.
-
parent
¶ Returns the repository from which this repository is forked from. Returns None if it has no fork relationship.
-
register_hook
(url: str, secret: Optional[str] = None, events: Optional[Set[IGitt.Interfaces.Repository.WebhookEvents]] = None)[source]¶ Registers a webhook to the given URL. Should pass silently if the hook already exists.
Parameters: - url – The URL to fire the webhook to.
- secret – An optional secret token to be registered with webhook.
- events – The set of events for which the webhook is to be registered against. Defaults to all possible events.
Raises: RuntimeError – If something goes wrong (network, auth…).
-
search_issues
(created_after: Optional[datetime.datetime] = None, created_before: Optional[datetime.datetime] = None, updated_after: Optional[datetime.datetime] = None, updated_before: Optional[datetime.datetime] = None, state: Optional[IGitt.Interfaces.IssueStates] = None)[source]¶ Retrieves a list of issues
-
search_mrs
(created_after: Optional[datetime.datetime] = None, created_before: Optional[datetime.datetime] = None, updated_after: Optional[datetime.datetime] = None, updated_before: Optional[datetime.datetime] = None, state: Optional[IGitt.Interfaces.MergeRequestStates] = None)[source]¶ Retrieves a list of prs
-
top_level_org
¶ Returns the topmost organization, e.g. for gitmate/open-source/IGitt this is gitmate.
-
IGitt.Interfaces.Team module¶
Contains the Team abstraction class.
-
class
IGitt.Interfaces.Team.
Team
[source]¶ Bases:
IGitt.Interfaces.IGittObject
Represents a team on GitHub or GitLab.
-
description
¶ Returns the description of this team.
-
get_organization
¶ Returns parent organization.
-
id
¶ Retrieves the id of the team.
-
members
¶ Returns the user handles of all members of this team.
-
name
¶ Name of the team.
-
IGitt.Interfaces.User module¶
Holds the User class representing users on such a platform.
-
class
IGitt.Interfaces.User.
User
[source]¶ Bases:
IGitt.Interfaces.IGittObject
Represents a user on GitHub/Lab. If you want to uniquely identify a user, use the id property as the id will never change while the username might.
-
identifier
¶ A unique ID used to identify the user. This is also given in oauth records.
-
installed_repositories
(installation_id: int) → Set[IGitt.Interfaces.Repository.Repository][source]¶ List repositories that are accessible to the authenticated user for an installation.
-
username
¶ The username of the user. Warning: this might change when the user renames himself!
-
Module contents¶
This package contains an abstraction for a git repository.
-
class
IGitt.Interfaces.
AccessLevel
[source]¶ Bases:
enum.Enum
Different access levels for users.
-
ADMIN
= 40¶
-
CAN_READ
= 20¶
-
CAN_VIEW
= 10¶
-
CAN_WRITE
= 30¶
-
NONE
= 0¶
-
OWNER
= 50¶
-
-
class
IGitt.Interfaces.
BasicAuthorizationToken
(username: str, password: str)[source]¶ Bases:
IGitt.Interfaces.Token
Basic HTTP Authorization using username and password.
-
auth
¶ A AuthBase instance that can be readily used to configure any kind of authentication easily with requests library.
-
headers
¶ Addtional headers are not required as HTTPBasicAuth is being used.
-
parameter
¶ Basic HTTP Authentication only refers to use of Authorization Header.
-
value
¶ Token value
-
-
class
IGitt.Interfaces.
IGittObject
[source]¶ Bases:
object
Any IGitt interface should inherit from this and any IGitt object shall have those methods.
-
hoster
¶ The hosting service of the object, e.g. ‘gitlab’ or ‘github’.
-
url
¶ Returns API url.
-
web_url
¶ Returns the web link.
-
-
class
IGitt.Interfaces.
IssueStates
[source]¶ Bases:
enum.Enum
This class depicts the issue states that can are present in any hosting service providers like GitHub or GitLab.
-
CLOSED
= 'closed'¶
-
OPEN
= 'open'¶
-
-
class
IGitt.Interfaces.
MergeRequestStates
[source]¶ Bases:
enum.Enum
This class depicts the merge request states that can are present in any hosting service providers like GitHub or GitLab.
-
CLOSED
= 'closed'¶
-
MERGED
= 'merged'¶
-
OPEN
= 'open'¶
-
-
class
IGitt.Interfaces.
MilestoneStates
[source]¶ Bases:
enum.Enum
This class depicts the milestone states that can are present in any hosting service providers like GitHub or GitLab.
-
CLOSED
= 'closed'¶
-
OPEN
= 'open'¶
-
-
class
IGitt.Interfaces.
Token
[source]¶ Bases:
object
Base class for different types of tokens used for different methods of authentications.
-
auth
¶ A AuthBase instance that can be readily used to configure any kind of authentication easily with requests library.
-
headers
¶ The Authorization headers.
-
parameter
¶ Parameter to be used for authentication
-
value
¶ Token value
-
-
IGitt.Interfaces.
delete
(token: IGitt.Interfaces.Token, url: str, data: Optional[dict] = None, headers: Optional[dict] = None, params: Optional[dict] = None)[source]¶ Sends a delete request to the given URL.
Parameters: - token – A token.
- url – The URL to access.
- params – The query params to be sent.
- headers – The request headers to be sent.
Raises: RuntimeError – If the response indicates any problem.
-
IGitt.Interfaces.
get
(token: IGitt.Interfaces.Token, url: str, params: Optional[dict] = None, headers: Optional[dict] = None)[source]¶ Queries the given URL for data.
Parameters: - token – A token.
- url – The URL to access.
- params – The query params to be sent.
- headers – The request headers to be sent.
Returns: A dictionary or a list of dictionary if the response contains multiple items (usually in case of pagination) and the HTTP status code.
Raises: RunTimeError – If the response indicates any problem.
-
IGitt.Interfaces.
get_response
(method: Callable, url: str, auth: requests.auth.AuthBase, json: Optional[Dict] = frozenset())[source]¶ Sends a request and returns the response. Also checks the response for errors, and keeps retrying unless it’s a HTTP Client Error.
-
IGitt.Interfaces.
is_client_error_or_unmodified
(exception)[source]¶ Returns true if the request responded with a client error.
-
IGitt.Interfaces.
lazy_get
(url: str, callback: Callable, headers: Optional[dict] = None, timeout: Optional[datetime.timedelta] = datetime.timedelta(0, 120), interval: Optional[datetime.timedelta] = datetime.timedelta(0, 10))[source]¶ Queries GitHub on the given URL for data, waiting while it returns HTTP 202.
Parameters: - url – The full URL to query.
- callback – The function to callback with data after data is obtained. An empty dictionary is sent if nothing is returned by the API.
- timeout – datetime.timedelta object with time to keep re-trying.
- interval – datetime.timedelta object with time to keep in between tries.
- headers – The request headers to be sent.
-
IGitt.Interfaces.
parse_response
(response: requests.models.Response)[source]¶ Parses the response object into JSON and link headers and returns them.
-
IGitt.Interfaces.
patch
(token: IGitt.Interfaces.Token, url: str, data: dict, headers: Optional[dict] = None)[source]¶ Patches the given data to the given URL.
Parameters: - token – A token.
- url – The URL to access.
- data – The data to patch.
- headers – The request headers to be sent.
Returns: A dictionary or a list of dictionary if the response contains multiple items (usually in case of pagination) and the HTTP status code.
Raises: RunTimeError – If the response indicates any problem.
-
IGitt.Interfaces.
post
(token: IGitt.Interfaces.Token, url: str, data: dict, headers: Optional[dict] = None)[source]¶ Posts the given data to the given URL.
Parameters: - token – A token.
- url – The URL to access.
- data – The data to post.
- headers – The request headers to be sent.
Returns: A dictionary or a list of dictionary if the response contains multiple items (usually in case of pagination) and the HTTP status code.
Raises: RunTimeError – If the response indicates any problem.
-
IGitt.Interfaces.
put
(token: IGitt.Interfaces.Token, url: str, data: dict, headers: Optional[dict] = None)[source]¶ Puts the given data to the given URL.
Parameters: - token – A token.
- url – The URL to access.
- data – The data to put.
- headers – The request headers to be sent.
Returns: A dictionary or a list of dictionary if the response contains multiple items (usually in case of pagination) and the HTTP status code.
Raises: RunTimeError – If the response indicates any problem.