Expand References

Automatically fetch content from links referenced in review comments.

Expand References is an advanced feature that fetches content from GitLab links mentioned in review comments, providing additional context for AI tools.

What It Does

When a reviewer includes a link to another piece of code (a specific line, file, or commit), Expand References fetches that content and includes it in the extraction.

Example comment:

The implementation here should match what we do in auth/validator.ts#L45.

With Expand References enabled, the extraction includes:

COMMENT (@reviewer):
The implementation here should match what we do in auth/validator.ts#L45.

LINK'S EXCERPT (auth/validator.ts#L45):
  function validateToken(token: string): boolean {
    const decoded = jwt.decode(token);
    return decoded !== null && !isExpired(decoded);
  }

Enabling the Feature

  1. Open the GitSniper popup
  2. Scroll to Advanced
  3. Check Expand References

The setting persists across sessions.

Expand References works with:

Line References

Links pointing to specific lines in a file:

  • repo/blob/main/file.ts#L45
  • repo/blob/main/file.ts#L45-L52 (line ranges)

File References

Links to entire files (first ~50 lines included):

  • repo/blob/main/src/utils/helper.ts

Commit References

Links to specific commits (commit message and summary included):

  • repo/commit/abc123

How Context is Captured

For line references, GitSniper fetches:

  • The exact lines referenced
  • A few surrounding lines for context
  • The file path for attribution

For larger ranges or files, content is truncated with an indicator showing what was omitted.

Platform Support

Expand References currently works best with GitLab links.

GitHub link expansion is limited because:

  • GitHub's API requires authentication for many resources
  • Rate limiting can affect large PRs with many links

GitLab's more permissive API allows broader link expansion.

Use Cases

Cross-Referencing Code

Reviewers often point to existing patterns:

"Follow the same approach as in UserService.ts"

Instead of manually finding that file, the relevant code is included automatically.

Commit History

When feedback references previous changes:

"This reverts the fix from commit abc123"

The referenced commit details are included.

Internal documentation links can be expanded to include the relevant content.

Limitations

Authentication

Links to private repositories or restricted content cannot be expanded without appropriate access. These appear as unresolved links in the output.

Only GitHub and GitLab links are processed. External documentation, Stack Overflow answers, and other sources are not expanded.

Rate Limiting

Rapid extractions with many links may hit API rate limits. If this happens, some links won't be expanded but the extraction still completes.

Large Files

When a link points to a very large file, only the first portion is included to keep output manageable.

Output Format

Expanded content appears immediately after the comment that referenced it:

COMMENT (@reviewer):
Check the validation logic in validator.ts#L23-L30.

LINK'S EXCERPT (validator.ts#L23-L30):
  if (!input.match(EMAIL_REGEX)) {
    return { valid: false, error: 'Invalid email format' };
  }
  if (input.length > MAX_EMAIL_LENGTH) {
    return { valid: false, error: 'Email too long' };
  }
  return { valid: true };

This keeps the referenced content in context with the comment that mentioned it.

When to Use

Enable Expand References when:

  • Reviews frequently reference other parts of the codebase
  • You're working on a large project where finding referenced code is time-consuming
  • The AI needs full context to understand suggestions

Consider disabling when:

  • Extractions are getting too long
  • Most comments are self-contained
  • You're hitting rate limits frequently