position

package
v1.23.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package position maps review findings onto GitLab diff positions: the base/head/start SHAs plus old/new path and line GitLab requires for an inline discussion. Findings that cannot be anchored return ErrUnresolved so callers can fall back to a general note.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnresolved = errors.New("line not present in the merge request diff")

ErrUnresolved means the finding's line is not part of any hunk in the MR diff; the comment can only be posted as a general note.

Functions

func Resolve

func Resolve(file string, oldLine, newLine *int, index []FileIndex, refs gitlabx.DiffRefs) (*gitlabx.Position, error)

Resolve maps a finding location (file plus old/new line as reported by the reviewer) to a GitLab position. The file is matched against the new path first, then the old path (deleted/renamed files); paths on the returned position always come from the diff entry, never the finding.

Types

type FileIndex

type FileIndex struct {
	OldPath string
	NewPath string
	// contains filtered or unexported fields
}

FileIndex is a parsed file diff: lookups from new-side and old-side line numbers to their classification.

func Index

func Index(diffs []gitlabx.FileDiff) []FileIndex

Index parses every file diff once so repeated resolutions are cheap.

type LineKind

type LineKind int

LineKind classifies one line of a parsed diff.

const (
	Added LineKind = iota
	Removed
	Context
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL