Skip to content

feat: Add ability to specify owning team via OWNING_TEAM environment variable#63

Merged
zkoppert merged 8 commits intomainfrom
copilot/fix-5a44b335-4f8a-4c35-b8fb-9f8941ab7116
Oct 1, 2025
Merged

feat: Add ability to specify owning team via OWNING_TEAM environment variable#63
zkoppert merged 8 commits intomainfrom
copilot/fix-5a44b335-4f8a-4c35-b8fb-9f8941ab7116

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 30, 2025

Summary

Adds the ability to specify a list of users as the owning team that overrides the built-in algorithm to determine who the owning team members are. This addresses situations where the first commit author doesn't represent the current team or when the org chart is misaligned with actual repository ownership.

Problem

The current team determination algorithm analyzes the first commit author and uses the org chart to build the team list. This can be problematic when:

  • The first commit author no longer works on the repository
  • The organizational structure doesn't match actual repository ownership
  • Teams want explicit control over who is considered the owning team

Solution

Introduces a new optional environment variable OWNING_TEAM that accepts a comma-separated list of GitHub usernames:

env:
  REPOSITORY: "org/repository"
  GH_TOKEN: ${{ secrets.GH_TOKEN }}
  OWNING_TEAM: "alice,bob,charlie,david"

When OWNING_TEAM is set, the tool:

  • Bypasses the first commit author analysis
  • Skips the org chart lookup for team determination
  • Uses the explicitly specified team members
  • Updates the report to show "Team ownership is explicitly specified"

When OWNING_TEAM is not set, the tool behaves exactly as before, maintaining full backward compatibility.

Changes

Configuration (config.py)

  • Added owning_team: list[str] | None field to EnvVars class
  • Implemented parsing for comma-separated usernames with whitespace handling
  • Filters out empty entries and treats empty/missing values as None

Core Logic (measure_innersource.py)

  • Added check for owning_team configuration at start of team determination
  • When set, uses the specified team and sets original_commit_author/original_commit_author_manager to None
  • Maintains all existing behavior when OWNING_TEAM is not provided

Report Generation (markdown_writer.py)

  • Enhanced to handle None values for original commit author and manager
  • Displays "Team ownership is explicitly specified" when using manual team override
  • Displays "Original Commit Author: X (Manager: Y)" when using the algorithm

Documentation (README.md)

  • Added OWNING_TEAM to configuration options table
  • Included detailed explanation in "Team Boundary Determination Algorithm" section
  • Added complete workflow example demonstrating usage
  • Updated environment variable checklist

Testing

  • Created test_config_owning_team.py with 7 test cases covering various input scenarios
  • Created test_markdown_writer_owning_team.py with 2 test cases for report generation
  • All 59 tests pass with zero linting errors and zero security issues

Example Usage

name: InnerSource with Custom Team

on:
  schedule:
    - cron: "0 0 * * 0"

jobs:
  measure-innersource:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: github/measure-innersource@v1
        env:
          REPOSITORY: "org/repository"
          GH_TOKEN: ${{ secrets.GH_TOKEN }}
          OWNING_TEAM: "alice,bob,charlie"

Backward Compatibility

✅ Fully backward compatible - existing workflows continue to work unchanged. The new feature is opt-in and only activates when OWNING_TEAM is explicitly set.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/github/github%2Fmeasure-innersource/languages
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>feat: Ability to specify a list of users or team as the owning team</issue_title>
<issue_description>### Is your feature request related to a problem?

The algorithm used to determine who the owning team is looks at the first commit author, and the current org chart which may be misaligned with who currently owns the repository.

Describe the solution you'd like

The ability to specify a list of users or team as the owning team that overrides the built in algorithm to determine who the owning team members are. This should be specified in a similar way to other configuration options and should be documented in the README.md.

Describe alternatives you've considered

none

Additional context

No response</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #23

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] feat: Ability to specify a list of users or team as the owning team feat: Add ability to specify owning team via OWNING_TEAM environment variable Sep 30, 2025
Copilot AI requested a review from zkoppert September 30, 2025 00:46
@zkoppert zkoppert marked this pull request as ready for review September 30, 2025 04:44
Copilot AI review requested due to automatic review settings September 30, 2025 04:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new feature to allow explicit specification of repository ownership through the OWNING_TEAM environment variable, providing an alternative to the automatic team determination algorithm.

  • Adds OWNING_TEAM environment variable to override the built-in team determination algorithm
  • Modifies core logic to use explicitly specified team members when provided
  • Updates report generation to display appropriate messaging based on team determination method

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
config.py Adds owning_team field to EnvVars class and parsing logic for comma-separated usernames
measure_innersource.py Implements team override logic to bypass original commit analysis when OWNING_TEAM is set
markdown_writer.py Updates report generation to handle explicit team specification vs algorithm-based determination
test_config_owning_team.py Comprehensive test suite for environment variable parsing with 7 test cases
test_markdown_writer_owning_team.py Test cases for report generation with both team determination methods
README.md Documentation updates including configuration table, algorithm section, and usage examples
.env-example Adds OWNING_TEAM to environment variable template

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread measure_innersource.py Outdated
Comment thread markdown_writer.py Outdated
This commit fixes an issue in the test where the mock commits setup was causing
an infinite loop. The changes include:

- Converting mock commits to a proper iterator to match real GitHub API behavior
- Fixing environment variable field names to align with actual main function usage
- Adding chunk_size to avoid issues in processing loops
- Adding additional assertions to verify early function exit

Tests that were previously hanging now complete successfully.

Signed-off-by: Zack Koppert <[email protected]>
Added test_markdown_writer_original_author_only.py to cover the specific case
where an original commit author is provided without a manager, ensuring that
the appropriate heading is written to the report markdown file.

Signed-off-by: Zack Koppert <[email protected]>
This change improves the clarity and maintainability of the codebase by:

- Adding an explicit `team_ownership_explicitly_specified` parameter to track when
  team ownership is provided explicitly rather than derived from commit history
- Updating logic in markdown_writer.py to prioritize this flag when determining
  report headings
- Adding a fallback message for cases where neither original author nor explicit
  team ownership is specified
- Setting flag value in measure_innersource.py based on owning_team parameter
- Adding comprehensive tests for the new parameter and updated behavior

This change makes the relationship between owning_team and report content more
explicit and handles edge cases more gracefully.

Signed-off-by: Zack Koppert <[email protected]>
…ficiency

This change improves memory usage and scalability for repositories with large
commit histories by:

- Replacing list(commits) with chunked processing to avoid loading the entire
  commit history into memory at once
- Using iterators directly to find the original commit author instead of
  loading all commits first
- Processing commits in manageable chunks based on the configured chunk_size,
  similar to how pull requests and issues are already handled
- Adding debug logging for commit processing progress

This approach ensures consistent memory usage regardless of repository size
and prevents potential out-of-memory issues when analyzing repositories with
extensive commit histories.

Signed-off-by: Zack Koppert <[email protected]>
@zkoppert zkoppert merged commit 62efffc into main Oct 1, 2025
33 checks passed
@zkoppert zkoppert deleted the copilot/fix-5a44b335-4f8a-4c35-b8fb-9f8941ab7116 branch October 1, 2025 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Ability to specify a list of users or team as the owning team

4 participants