Documentation ¶
Index ¶
- Constants
- Variables
- func CLNumber(revision string) string
- func CommentIsInChangedLines(c context.Context, data *tricium.Data_Comment, changedLines ChangedLinesInfo, ...) bool
- func CreateURL(host, revision string) string
- func ExtractCLPatchSetNumbers(revision string) (string, string)
- func FilterRequestChangedLines(request *track.AnalyzeRequest, changedLines *ChangedLinesInfo)
- func IsGerritProjectRequest(request *track.AnalyzeRequest) bool
- func PatchSetNumber(revision string) string
- type API
- type ChangedLinesInfo
- type MockRestAPI
- func (m *MockRestAPI) GetChangedLines(c context.Context, host, change, revision string) (ChangedLinesInfo, error)
- func (m *MockRestAPI) PostRobotComments(c context.Context, host, change, revision string, runID int64, ...) error
- func (*MockRestAPI) QueryChanges(c context.Context, host, project string, ts time.Time) ([]gr.ChangeInfo, bool, error)
Constants ¶
const ( // MaxChanges is the max number of changes to request from Gerrit. // // This should be a number small enough so that it can be handled in one // request, but also large enough to avoid skipping over changes. MaxChanges = 60 )
Variables ¶
var GerritServer gerritServer
GerritServer implements RestAPI for the Gerrit service.
Functions ¶
func CommentIsInChangedLines ¶
func CommentIsInChangedLines(c context.Context, data *tricium.Data_Comment, changedLines ChangedLinesInfo, numNearbyLines int) bool
CommentIsInChangedLines returns true whether a comment is in or close enough to the change.
Comments on the change description and comments within numNearbyLines of changed lines are included.
func ExtractCLPatchSetNumbers ¶
ExtractCLPatchSetNumbers extracts CL/patch numbers from a revision ref.
func FilterRequestChangedLines ¶
func FilterRequestChangedLines(request *track.AnalyzeRequest, changedLines *ChangedLinesInfo)
FilterRequestChangedLines will remove changed lines for all files in |request| that should be ignored when considering whether to post a comment to the file.
func IsGerritProjectRequest ¶
func IsGerritProjectRequest(request *track.AnalyzeRequest) bool
IsGerritProjectRequest determines if the |request| is for a Gerrit project.
func PatchSetNumber ¶
PatchSetNumber extracts the patch set number from a revision ref.
Types ¶
type API ¶
type API interface { // QueryChanges sends one query for changes to Gerrit using the provided // poll data. // // The poll data is assumed to correspond to the last seen change before // this poll. Even though Gerrit supports paging, we only make one request // to Gerrit because polling too many changes can quickly use up too much // memory and time. // // A list of changes is returned in the same order as they were returned by // Gerrit. The result tuple includes a boolean value to indicate if the // result was truncated. QueryChanges(c context.Context, host, project string, lastTimestamp time.Time) ([]gr.ChangeInfo, bool, error) // PostRobotComments posts robot comments to a change. PostRobotComments(c context.Context, host, change, revision string, runID int64, comments []*track.Comment) error // GetChangedLines requests the diff info for all files for a // particular revision and extracts the lines in the "new" post-patch // version that are considered changed. GetChangedLines(c context.Context, host, change, revision string) (ChangedLinesInfo, error) }
API specifies the Gerrit REST API tuned to the needs of Tricium.
type ChangedLinesInfo ¶
ChangedLinesInfo contains the line numbers that have been touched in particular change. The string key is the file name (in posix form), and the value is a list of changed (i.e. added or modified) lines (sorted) in the destination file.
type MockRestAPI ¶
type MockRestAPI struct { LastMsg string LastComments []*track.Comment ChangedLines ChangedLinesInfo }
MockRestAPI mocks the GerritAPI interface for testing.
Remembers the last posted message and comments.
func (*MockRestAPI) GetChangedLines ¶
func (m *MockRestAPI) GetChangedLines(c context.Context, host, change, revision string) (ChangedLinesInfo, error)
GetChangedLines requests the diff info for all files for a particular revision and extracts the lines in the "new" post-patch version that are considered changed.
func (*MockRestAPI) PostRobotComments ¶
func (m *MockRestAPI) PostRobotComments(c context.Context, host, change, revision string, runID int64, comments []*track.Comment) error
PostRobotComments posts robot comments to a change.
func (*MockRestAPI) QueryChanges ¶
func (*MockRestAPI) QueryChanges(c context.Context, host, project string, ts time.Time) ([]gr.ChangeInfo, bool, error)
QueryChanges sends one query for changes to Gerrit using the provided poll data.