跳到正文
DEV Community· Cole Halton·· 6 小時前AI 評分65

68% 的 squash 提交帶有 AI trailer,merge 提交只有 8%

68% of squashed commits carry an AI trailer. 8% of merge commits do.

AI 導讀

作者抽查 18 個曾合併 Copilot 或 Devin PR 的公開儲存庫,共 469 個提交;單一父提交中有 68.1% 帶有 AI trailer,雙父 merge 提交則為 8.5%。作者指出,署名資訊由智能體自願加入,該比例反映合併方式與署名留存,並非 AI 編寫程式碼的比例。

正文

I went looking for how much AI authorship actually survives into a repo's mainline. Not "how much AI code is written" (unmeasurable), just: when an agent opens a PR and it merges, can you still tell an agent was involved after the fact?

The answer depends almost entirely on which merge button got pressed, and the gap is bigger than I expected.

I sampled 18 public repos that merged a Copilot or Devin PR in the week of 2026-11-08, pulled the 30 most recent commits from each repo's default branch, and classified every commit two ways: how many parents it has, and whether its message carries an AI trailer (Co-authored-by: Copilot <...> or similar).

469 commits. 339 had a single parent. 130 had two.

  • single-parent commits: 231 of 339 carry an AI trailer = 68.1%
  • two-parent merge commits: 11 of 130 carry one = 8.5%

Same repos, same branch, same week. An 8x gap that has nothing to do with how much code the agent wrote.

Why the merge commit is a dead end for attribution

A default GitHub merge commit message is exactly this:

Merge pull request #9 from Akintanoreofe/copilot/cropped-silhouette-calibration

Improve cropped-video validation and silhouette alignment

That is the whole thing. GitHub does not concatenate the branch commits' messages into the merge commit. The trailer lives on the branch commit, the merge commit is a fresh object with a two-line message, and nothing carries the metadata across.

Squash behaves the opposite way. The default squash message is built from the commit title and message when the PR has one commit, so a Co-authored-by trailer rides along into the squashed commit on main.

I checked that per PR rather than trusting the aggregate. Eight merged agent PRs, same trailer on the head commit in all of them:

repo PR parents AI trailer on merge
maxffarrell/freeweight #462 1 (squash) yes
maxffarrell/tredaro #280 1 (squash) yes
aryashahprog/aryashah #7 2 (merge) no
reputationly/new-api #96 2 (merge) no
Akintanoreofe/BroilerWeightEstimation #9 2 (merge) no
lotteharper/misc #58 2 (merge) no
iama2z/Eagle-Deep-Dive-Daily #57 2 (merge) no
Alfetta159/TabloWatcherService #106 2 (merge) no

len(parents) is the check, not the commit message. One API call on /repos/{owner}/{repo}/commits/{merge_commit_sha} tells you which world you're in.

GitHub's own docs are honest about this for squash, in the merge methods page: "You lose information about when specific changes were originally made and who authored the squashed commits."

What the docs don't spell out is that the merge commit path is just as lossy, for a different reason. Squash destroys the authorship of individual commits but often keeps the trailer. A merge commit keeps every branch commit intact but never copies the trailer up. If you only look at mainline, both look like normal history.

The grep trap that makes your attribution look healthier than it is

Before I got to any of this I did the lazy version: search merge commit messages for copilot or devin. That matched 8 of 12 merged agent PRs, which felt like a decent survival rate.

Only 4 of those 8 had an actual trailer. The other 4 matched the branch name:

Merge pull request #7 from aryashahprog/devin/1794700572-custom-domain
Merge pull request #9 from Akintanoreofe/copilot/cropped-silhouette-calibration

Line one of the default merge message embeds the head branch, and agent tools name branches after themselves. So a substring grep on the commit message has a 50% false-positive rate in my sample, and the errors all point one direction: they make attribution look like it survived when it didn't.

The fix is to anchor on the trailer form instead of the vendor name:

TRAIL = re.compile(r"(?im)^\s*(co-authored-by|generated-by|assisted-by)\s*:\s*(.+)$")
AIID  = re.compile(r"(?i)(copilot|devin|claude|\[bot\]|bot@|swe-agent)")
hits = [v for k, v in TRAIL.findall(message) if AIID.search(v)]

Match the key at line start, then filter the value. git-interpret-trailers defines the trailer block as needing a preceding blank line and living at the end of the message, which is why anchoring matters: Co-authored-by mentioned mid-sentence in a description is not a trailer.

Identity strings are not one string

In that one sample I saw three distinct identities for two vendors:

Copilot <223556219+Copilot@users.noreply.github.com>
copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Same product, three strings, and they change over time. Match by prefix. If you're comparing counts across vendors, an equality check on the identity will silently drop rows and you'll read that as "this vendor doesn't leave trailers."

What this does and doesn't tell you

The trailer only exists because the agent volunteers it. Nothing in git enforces it, no hook rejects a commit without it, and a human can edit it out or never add it. So 68% is a floor on how much volunteered attribution reaches mainline, not a measure of AI-written code.

That's why the number matters more than it looks. A commit-trailer check is the cheapest provenance signal available in a PR, and it's silently merge-method dependent. Teams that switch from merge commits to squash (or the reverse) change their own measured AI-authorship rate without changing anything about how they write code. If you have a dashboard or a compliance check that counts trailers, it's measuring your repo settings.

If you want the audit to hold up, the protocol is five steps:

  1. Resolve the bot login from the PR search API (author:app/copilot-swe-agent), never from memory. Wrong login returns total_count: 0, which is indistinguishable from "this vendor leaves no attribution."
  2. Read the trailer off /repos/{owner}/{repo}/pulls/{n}/commits. The head branch, not the default branch.
  3. Read /repos/{owner}/{repo}/commits/{merge_commit_sha} and check len(parents). One parent means squash or rebase; two means a real merge commit.
  4. Regex the trailer key at line start, then filter the value for a vendor or bot pattern.
  5. Report the window and the sample size with every rate. I measured the same behavior at 8/12 and at 2/8 in different cuts of the same week, and neither number means anything without the other.

That last point is the one I keep re-learning. Rates here are not properties of a tool, they're properties of a repo's merge configuration plus whatever slice you happened to grab. Squash-merge-heavy repos look well-attributed. Merge-commit repos look like nobody uses AI. Both descriptions can be true of the same codebase on the same day.

Related, if you're auditing the review side rather than the authorship side: 9 of 28 merged PRs had code the AI reviewer never saw and merged agent PRs with zero reviews both use the same commit-level reading, and both hit the same problem where the artifact you're counting isn't the artifact you think you're counting.

來源:DEV Community · dev.to