Enhancing Developer Activity: Sorting GitHub Issues by Commit Timestamp

Keeping track of relevant issues is a daily challenge for developers. While GitHub provides various sorting options, a recent community discussion highlighted a key limitation: the inability to sort issues by their "commit timestamp." This gap impacts how teams monitor developer activity and prioritize work, as issues with recent code changes might be overlooked if they haven't received a direct comment or label update.

Developer sorting GitHub issues by commit timestamp.
Developer sorting GitHub issues by commit timestamp.

The Challenge: When "Recently Updated" Falls Short

GitHub's standard "Recently updated" sort order doesn't account for commits that reference an issue. For many developers, especially when managing a cross-repository "TODO" list, the most critical update is often a linked commit, not a new comment. This means actively worked-on issues can appear dormant, hindering efficient workflow and accurate insights into engineering performance.

The reason lies in GitHub's architecture: an issue's updated_at attribute only increments for direct mutations (comments, edits, labels). When a commit references an issue, a ReferencedEvent is added to the timeline, but updated_at is not updated. This prevents mass notifications from historical pushes or rebases, which could otherwise flood feeds with old issues.

Technical solutions for tracking commit activity in GitHub issues.
Technical solutions for tracking commit activity in GitHub issues.

Community-Driven Solutions for Enhanced Tracking

Despite these architectural reasons, the community has devised practical workarounds to gain better visibility into commit-related developer activity:

1. Instant Local Git Command

For quick, repository-specific insights, a local Git command can list commits referencing issues, ordered by commit timestamp:

git log --all --grep="#[0-9]\+" --date=iso-strict --pretty=format:"%ad | commit %h | %s"

2. Querying via GitHub GraphQL API

For programmatic access across remote issues, the GitHub GraphQL API allows inspection of the issue timeline for ReferencedEvent and extraction of the commit's committedDate:

query($owner: String!, $repo: String!) {
  repository(owner: $owner, name: $repo) {
    issues(first: 20, states: OPEN) {
      nodes {
        number
        title
        timelineItems(last: 1, itemTypes: [REFERENCED_EVENT]) {
          nodes {
            ... on ReferencedEvent {
              createdAt
              commit {
                oid
                message
                committedDate
              }
            }
          }
        }
      }
    }
  }
}

3. GitHub Projects (v2) Automation

Teams using GitHub Projects can enhance tracking:

  • Projects track updated and merged timestamps of linked pull requests.
  • Automated workflows (e.g., GitHub Actions on push) can write github.event.head_commit.timestamp to a custom Project date field, enabling sorting by recent commit activity within the Project table view.

4. Custom Scripting with GitHub REST API

For cross-repository needs, a custom Python script can fetch issues and their events, then sort them by the latest relevant event, including commit references. This example, shared by the original poster, illustrates how custom tools can prioritize issues based on a broader definition of "activity."

def _repos(user: string):
    """Users repos."""
    url = f'https://api.github.com/users/{user}/repos'
    with urllib.request.urlopen(url) as resp:
        for data in json.loads(resp.read()):
            yield data['url']

def _issues(repo_url, assignee):
    """User issues."""
    url = f'{repo_url}/issues?assignee={assignee}'
    with urllib.request.urlopen(url) as resp:
        for data in json.loads(resp.read()):
            yield data

def _events(events_url):
    """Issue events."""
    with urllib.request.urlopen(events_url) as resp:
        for data in json.loads(resp.read()):
            if data['event'] not in ('blocked_by_added', 'labeled', 'blocking_added', 'blocking_removed', 'pinned', 'renamed'):
                yield data

def user(user_name) -> int:
    """Find stuff about user."""
    issues = list()
    for repo_url in _repos(user_name):
        for issue in _issues(repo_url, user_name):
            events = list()
            for event in _events(issue['events_url']):
                events.append((
                    datetime.datetime.fromisoformat(event['created_at']).timestamp(),
                    event['event'],
                    event['actor']['login'],
                ))
            event = max(events)
            issues.append((event, issue['html_url']))
    for issue in sorted(issues):
        print(issue)

Boosting Productivity and Retrospective Insights

This discussion highlights a common developer need for granular control over issue tracking. These community-driven solutions offer powerful ways to gain deeper insights into developer activity, improving individual engineering performance, streamlining project management, and providing more accurate data for effective sprint retrospective meeting discussions.

|

Dashboards, alerts, and review-ready summaries built on your GitHub activity.

 Install GitHub App to Start
Dashboard with engineering activity trends