Skip to content

How Gitar’s Feature Flag Cleanup Works

Gitar’s feature flag cleanup product removes stale feature flags from a repo by rewriting code to replace calls to a feature flag library with the flag’s final value. Gitar performs feature flag cleanup using traditional compiler and code analysis techniques. It parses the source code into an internal representation, analyzes this representation to find stale feature flag references, replaces them with the final value of the flag, and finally cleans up the code using compiler optimization techniques to delete code that becomes unnecessary as a result of removing the feature flag. The core rewrite engine is forked from the open source Piranha project.

The details on how this technology works is published in this ACM paper and in these blog posts:

Gitar runs as a managed cloud service (currently running in AWS) that accesses git repos and creates PRs via GitHub.

Gitar service

The Gitar service is installed as a GitHub app from the GitHub marketplace. This app allows a user to trigger a flag cleanup by adding a @gitar-bot comment on any GitHub issue or PR. The Gitar cloud service receives webhook events from the GitHub app that invoke its feature flag cleanup.

The Gitar service

  1. checks out a copy of a repo,
  2. applies its transformations to cleanup a feature flag,
  3. posts a PR back to GitHub or GitLab, and then
  4. deletes the checked out copy of the git repo.

Gitar does not retain any of the checked code after posting the PR.