• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

release-engineering / Sync2Jira / 18378802996

09 Oct 2025 01:59PM UTC coverage: 73.221% (-5.0%) from 78.204%
18378802996

Pull #378

github

web-flow
Merge 2ce53e22f into e93012104
Pull Request #378: Add gitlab support

362 of 553 branches covered (65.46%)

Branch coverage included in aggregate %.

72 of 182 new or added lines in 7 files covered. (39.56%)

1 existing line in 1 file now uncovered.

945 of 1232 relevant lines covered (76.7%)

0.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.31
/sync2jira/handler/github.py
1
import logging
1✔
2

3
# Local Modules
4
import sync2jira.downstream_issue as d_issue
1✔
5
import sync2jira.downstream_pr as d_pr
1✔
6
import sync2jira.handler.github_upstream_issue as u_issue
1✔
7
import sync2jira.handler.github_upstream_pr as u_pr
1✔
8
from sync2jira.intermediary import matcher
1✔
9

10
log = logging.getLogger("sync2jira")
1✔
11

12

13
def handle_issue_msg(body, headers, suffix, config):
1✔
14
    """
15
    Function to handle incoming github issue message
16
    :param Dict body: Incoming message body
17
    :param Dict headers: Incoming message headers
18
    :param String suffix: Incoming suffix
19
    :param Dict config: Config dict
20
    """
21
    # GitHub '.issue*' is used for both PR and Issue; check if this update
22
    # is actually for a PR
23
    if "pull_request" in body["issue"]:
1!
NEW
24
        if body["action"] == "deleted":
×
25
            # I think this gets triggered when someone deletes a comment
26
            # from a PR.  Since we don't capture PR comments (only Issue
27
            # comments), we don't need to react if one is deleted.
NEW
28
            log.debug("Not handling PR 'action' == 'deleted'")
×
NEW
29
            return
×
30
        # Handle this PR update as though it were an Issue, if that's
31
        # acceptable to the configuration.
NEW
32
        if not (pr := u_issue.handle_github_message(body, config, is_pr=True)):
×
NEW
33
            log.info("Not handling PR issue update -- not configured")
×
NEW
34
            return
×
35
        # PRs require additional handling (Issues do not have suffix, and
36
        # reporter needs to be reformatted).
NEW
37
        pr.suffix = suffix
×
NEW
38
        pr.reporter = pr.reporter.get("fullname")
×
NEW
39
        setattr(pr, "match", matcher(pr.content, pr.comments))
×
NEW
40
        d_pr.sync_with_jira(pr, config)
×
41
    else:
42
        if issue := u_issue.handle_github_message(body, config):
1✔
43
            d_issue.sync_with_jira(issue, config)
1✔
44
        else:
45
            log.info("Not handling Issue update -- not configured")
1✔
46

47

48
def handle_pr_msg(body, headers, suffix, config):
1✔
49
    """
50
    Function to handle incoming github PR message
51
    :param Dict body: Incoming message body
52
    :param Dict headers: Incoming message headers
53
    :param String suffix: Incoming suffix
54
    :param Dict config: Config dict
55
    """
56
    if pr := u_pr.handle_github_message(body, config, suffix):
1!
57
        d_pr.sync_with_jira(pr, config)
1✔
58
    else:
NEW
59
        log.info("Not handling PR update -- not configured")
×
60

61

62
# Issue related handlers
63
issue_handlers = {
1✔
64
    # GitHub
65
    # New webhook-2fm topics
66
    "github.issues": handle_issue_msg,
67
    "github.issue_comment": handle_issue_msg,
68
    # Old github2fedmsg topics
69
    "github.issue.opened": handle_issue_msg,
70
    "github.issue.reopened": handle_issue_msg,
71
    "github.issue.labeled": handle_issue_msg,
72
    "github.issue.assigned": handle_issue_msg,
73
    "github.issue.unassigned": handle_issue_msg,
74
    "github.issue.closed": handle_issue_msg,
75
    "github.issue.comment": handle_issue_msg,
76
    "github.issue.unlabeled": handle_issue_msg,
77
    "github.issue.milestoned": handle_issue_msg,
78
    "github.issue.demilestoned": handle_issue_msg,
79
    "github.issue.edited": handle_issue_msg,
80
}
81

82
# PR related handlers
83
pr_handlers = {
1✔
84
    # GitHub
85
    # New webhook-2fm topics
86
    "github.pull_request": handle_pr_msg,
87
    "github.issue_comment": handle_pr_msg,
88
    # Old github2fedmsg topics
89
    "github.pull_request.opened": handle_pr_msg,
90
    "github.pull_request.edited": handle_pr_msg,
91
    "github.issue.comment": handle_pr_msg,
92
    "github.pull_request.reopened": handle_pr_msg,
93
    "github.pull_request.closed": handle_pr_msg,
94
}
95

96

97
def get_handler_for(suffix, topic, idx):
1✔
98
    """
99
    Function to check if a handler for given suffix is configured
100
    :param String suffix: Incoming suffix
101
    :param String topic: Topic of incoming message
102
    :param String idx: Id of incoming message
103
    :returns: Handler function if configured for suffix. Otherwise None.
104
    """
105
    if suffix in issue_handlers:
1✔
106
        return issue_handlers.get(suffix)
1✔
107
    elif suffix in pr_handlers:
1✔
108
        return pr_handlers.get(suffix)
1✔
109
    log.info("No github handler for %r %r %r", suffix, topic, idx)
1✔
110
    return None
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc