Skip to content

Commit

Permalink
Merge pull request #191 from mathstuf/gitlab-support
Browse files Browse the repository at this point in the history
gitlab: add initial gitlab support
  • Loading branch information
ralphbean committed Feb 7, 2015
2 parents ce5b8ff + 8215127 commit ed9af7f
Show file tree
Hide file tree
Showing 6 changed files with 574 additions and 14 deletions.
28 changes: 15 additions & 13 deletions bugwarrior/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,35 @@ bugwarrior - Pull tickets from github, bitbucket, bugzilla, jira, trac, and othe

It currently supports the following remote resources:

- `github <http://github.com>`_ (api v3)
- `bitbucket <http://bitbucket.org>`_
- `trac <http://trac.edgewall.org/>`_
- `bugzilla <http://www.bugzilla.org/>`_
- `megaplan <http://www.megaplan.ru/>`_
- `teamlab <http://www.teamlab.com/>`_
- `redmine <http://www.redmine.org/>`_
- `jira <http://www.atlassian.com/software/jira/overview>`_
- `activecollab <http://www.activecollab.com>`_ (2.x and 4.x)
- `github <https://github.com>`_ (api v3)
- `gitlab <https://gitlab.com>`_ (api v3)
- `bitbucket <https://bitbucket.org>`_
- `trac <https://trac.edgewall.org/>`_
- `bugzilla <https://www.bugzilla.org/>`_
- `megaplan <https://www.megaplan.ru/>`_
- `teamlab <https://www.teamlab.com/>`_
- `redmine <https://www.redmine.org/>`_
- `jira <https://www.atlassian.com/software/jira/overview>`_
- `activecollab <https://www.activecollab.com>`_ (2.x and 4.x)
- `phabricator <http://phabricator.org/>`_
- `versionone <http://http://www.versionone.com/>`_
- `versionone <http://www.versionone.com/>`_

Documentation
-------------

For information on how to install and use bugwarrior, read `the docs
<http://bugwarrior.rtfd.org>`_ on RTFD.
<https://bugwarrior.rtfd.org>`_ on RTFD.

Build Status
------------

.. |master| image:: https://secure.travis-ci.org/ralphbean/bugwarrior.png?branch=master
:alt: Build Status - master branch
:target: http://travis-ci.org/#!/ralphbean/bugwarrior
:target: https://travis-ci.org/#!/ralphbean/bugwarrior

.. |develop| image:: https://secure.travis-ci.org/ralphbean/bugwarrior.png?branch=develop
:alt: Build Status - develop branch
:target: http://travis-ci.org/#!/ralphbean/bugwarrior
:target: https://travis-ci.org/#!/ralphbean/bugwarrior

+----------+-----------+
| Branch | Status |
Expand All @@ -49,6 +50,7 @@ Contributors
------------

- Ralph Bean (primary author)
- Ben Boeckel(contributed support for Gitlab)
- Justin Forest (contributed support for RedMine, TeamLab, and MegaPlan, as
well as some unicode help)
- Tycho Garen (contributed support for Jira)
Expand Down
2 changes: 1 addition & 1 deletion bugwarrior/docs/services/github.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ the ``github`` service name.
Example Service
---------------

Here's an example of an Github target::
Here's an example of a Github target::

[my_issue_tracker]
service = github
Expand Down
119 changes: 119 additions & 0 deletions bugwarrior/docs/services/gitlab.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
Gitlab
======

You can import tasks from your Gitlab instance using
the ``gitlab`` service name.

Example Service
---------------

Here's an example of a Gitlab target::

[my_issue_tracker]
service = gitlab
gitlab.username = ralphbean
gitlab.login = ralphbean
gitlab.token = OMG_LULZ

The above example is the minimum required to import issues from
Gitlab. You can also feel free to use any of the
configuration options described in :ref:`common_configuration_options`
or described in `Service Features`_ below.

Note that both ``gitlab.username`` and ``gitlab.login`` are required and can be
set to different values. ``gitlab.login`` is used to specify what account
bugwarrior should use to login to gitlab. ``gitlab.username`` indicates which
repositories should be scraped. For instance, I always have ``gitlab.login``
set to ralphbean (my account). But I have some targets with
``gitlab.username`` pointed at organizations or other users to watch issues
there. The ``gitlab.token`` is your private API token.

Service Features
----------------

Include and Exclude Certain Repositories
++++++++++++++++++++++++++++++++++++++++

If you happen to be working with a large number of projects, you
may want to pull issues from only a subset of your repositories. To
do that, you can use the ``gitlab.include_repos`` option.

For example, if you would like to only pull-in issues from
your ``project_foo`` and ``project_fox`` repositories, you could add
this line to your service configuration::

gitlab.include_repos = project_foo,project_fox

Alternatively, if you have a particularly noisy repository, you can
instead choose to import all issues excepting it using the
``gitlab.exclude_repos`` configuration option.

In this example, ``noisy_repository`` is the repository you would
*not* like issues created for::

gitlab.exclude_repos = noisy_repository

Import Labels as Tags
+++++++++++++++++++++

The gitlab issue tracker allows you to attach labels to issues; to
use those labels as tags, you can use the ``gitlab.import_labels_as_tags``
option::

gitlab.import_labels_as_tags = True

Also, if you would like to control how these labels are created, you can
specify a template used for converting the gitlab label into a Taskwarrior
tag.

For example, to prefix all incoming labels with the string 'gitlab_' (perhaps
to differentiate them from any existing tags you might have), you could
add the following configuration option::

gitlab.label_template = gitlab_{{label}}

In addition to the context variable ``{{label}}``, you also have access
to all fields on the Taskwarrior task if needed.

.. note::

See :ref:`field_templates` for more details regarding how templates
are processed.

Include Merge Requests
++++++++++++++++++++++

Although you can filter issues using :ref:`common_configuration_options`,
merge requests are not filtered by default. You can filter merge requests
by adding the following configuration option::

gitlab.filter_merge_requests = False

Provided UDA Fields
-------------------

+-----------------------+-----------------------+---------------------+
| Field Name | Description | Type |
+=======================+=======================+=====================+
| ``gitlabdescription`` | Description | Text (string) |
+-----------------------+-----------------------+---------------------+
| ``gitlabcreatedon`` | Created | Date & Time |
+-----------------------+-----------------------+---------------------+
| ``gitlabmilestone`` | Milestone | Text (string) |
+-----------------------+-----------------------+---------------------+
| ``gitlabnumber`` | Issue/MR # | Numeric |
+-----------------------+-----------------------+---------------------+
| ``gitlabtitle`` | Title | Text (string) |
+-----------------------+-----------------------+---------------------+
| ``gitlabtype`` | Type | Text (string) |
+-----------------------+-----------------------+---------------------+
| ``gitlabupdatedat`` | Updated | Date & Time |
+-----------------------+-----------------------+---------------------+
| ``gitlaburl`` | URL | Text (string) |
+-----------------------+-----------------------+---------------------+
| ``gitlabrepo`` | username/reponame | Text (string) |
+-----------------------+-----------------------+---------------------+
| ``gitlabupvotes`` | Number of upvotes | Numeric |
+-----------------------+-----------------------+---------------------+
| ``gitlabdownvotes`` | Number of downvotes | Numeric |
+-----------------------+-----------------------+---------------------+
3 changes: 3 additions & 0 deletions bugwarrior/services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ def build_default_description(
cls_markup = {
'issue': 'Is',
'pull_request': 'PR',
'merge_request': 'MR',
'task': '',
'subtask': 'Subtask #',
}
Expand Down Expand Up @@ -546,6 +547,7 @@ def aggregate_issues(conf, main_section):
from .bitbucket import BitbucketService
from .bz import BugzillaService
from .github import GithubService
from .gitlab import GitlabService
from .teamlab import TeamLabService
from .redmine import RedMineService
from .trac import TracService
Expand All @@ -554,6 +556,7 @@ def aggregate_issues(conf, main_section):
# Constant dict to be used all around town.
SERVICES = {
'github': GithubService,
'gitlab': GitlabService,
'bitbucket': BitbucketService,
'trac': TracService,
'bugzilla': BugzillaService,
Expand Down
Loading

0 comments on commit ed9af7f

Please sign in to comment.