diff

package
v1.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//Detected a Continuous Integration environment
	Detected = CIDetected(true)
	//NotDetected a Continuous Integration environment
	NotDetected = CIDetected(false)
)

Variables

View Source
var AllDefinedTools = []*ToolDefinition{
	defineBeyondCompare(),
	defineAraxisMerge(),
	defineCodeCompare(),
	defineDeltaWalker(),
	defineDiffinity(),
	defineDiffMerge(),
	defineExamDiff(),
	defineGuiffy(),
	defineKaleidoscope(),
	defineKDiff3(),
	defineMeld(),
	defineNeovim(),
	defineP4MergeImage(),
	defineP4MergeText(),
	defineGoland(),
	defineSublimeMerge(),
	defineTkDiff(),
	defineTortoiseGitMerge(),
	defineTortoiseDiff(),
	defineTortoiseMerge(),
	defineVim(),
	defineVsCode(),
	defineWinMerge(),
}

AllDefinedTools definition of all supported diff tools

Functions

func CheckDisabled

func CheckDisabled() bool

func Kill

func Kill(tempFile, targetFile string)

Kill the diff tool if it doesn't support MDI, is already running and has been opened to display a specific temp and target file.

Types

type BuildArguments

type BuildArguments = func(tempFile string, targetFile string) []string

BuildArguments a function to build arguments to launch a diff tool

type BuildServerEnvironment

type BuildServerEnvironment string

BuildServerEnvironment environment variable or lookup key to detect CI environment

const (
	//Appveyor build environment
	Appveyor BuildServerEnvironment = "CI"
	//Jenkins build environment
	Jenkins BuildServerEnvironment = "JENKINS_URL"
	//GitHub actions build environment
	GitHub BuildServerEnvironment = "GITHUB_ACTION"
	//AzureDevOps build environment
	AzureDevOps BuildServerEnvironment = "AGENT_ID"
	//TeamCity build environment
	TeamCity BuildServerEnvironment = "TEAMCITY_VERSION"
	//MyGet build environment
	MyGet BuildServerEnvironment = "BuildRunner"
	//GitLab build environment
	GitLab BuildServerEnvironment = "GITLAB_CI"
)

type CIDetected

type CIDetected bool

CIDetected result of detection of Continuous Integration check

func CheckCI

func CheckCI() CIDetected

CheckCI checks for Continuous Integration environment being present

type EnvReader

type EnvReader interface {
	LookupEnv(key string) (string, bool)
}

EnvReader reads environment variables

type LaunchResult

type LaunchResult int

LaunchResult result of the launch operation of the diff tool

const (
	//NoLaunchResult no result specified
	NoLaunchResult LaunchResult = iota
	//NoEmptyFileForExtension when no empty file can be created for the diff tool
	NoEmptyFileForExtension
	//AlreadyRunningAndSupportsRefresh the diff tool is already running and supports auto refresh
	AlreadyRunningAndSupportsRefresh
	//StartedNewInstance a new instance of the diff tool can be created
	StartedNewInstance
	//TooManyRunningDiffTools too many instance of the diff tool is running
	TooManyRunningDiffTools
	//NoDiffToolFound no diff tool was found on the machine
	NoDiffToolFound
	//Disabled diff tools are disabled
	Disabled
)

func Launch

func Launch(tempFile, targetFile string) LaunchResult

Launch a new diff tool

type Logger

type Logger interface {
	Error(err error)
	Info(format string, args ...interface{})
	EnableLogging()
}

Logger interface to log info and error logs

type OsSettings

type OsSettings struct {
	TargetLeftArguments  BuildArguments
	TargetRightArguments BuildArguments
	ExePaths             []string
}

OsSettings provides path to the diff file and require arguments for the launch

func NewOsSettings

func NewOsSettings(
	targetLeftArguments BuildArguments,
	targetRightArguments BuildArguments,
	exePaths []string) *OsSettings

NewOsSettings creates a new instance of OsSettings

type PriceModel

type PriceModel string

PriceModel of the detected diff tool

const (
	Paid PriceModel = "Paid"
	//Free diff tool
	Free PriceModel = "Free"
	//Donation free with donation options
	Donation PriceModel = "Free with option to donate"
	Sponsor PriceModel = "Free with option to sponsor"
)

type ResolvedTool

type ResolvedTool struct {
	Name             string
	Kind             ToolKind
	ExePath          string
	RightArguments   BuildArguments
	LeftArguments    BuildArguments
	IsMdi            bool
	AutoRefresh      bool
	BinaryExtensions []string
	RequiresTarget   bool
	SupportsText     bool
}

ResolvedTool contains information about a found diff tool

type ToolDefinition

type ToolDefinition struct {
	Kind             ToolKind
	Url              string
	AutoRefresh      bool
	IsMdi            bool
	Windows          OsSettings
	Linux            OsSettings
	Osx              OsSettings
	BinaryExtensions []string
	Cost             PriceModel
	Notes            string
	SupportsText     bool
	RequiresTarget   bool
}

ToolDefinition specifies attributes of a diff tool

type ToolKind

type ToolKind string

ToolKind specifies the kind of the diff tool detected

const (
	//None no tool
	None ToolKind = ""
	//BeyondCompare diff tool
	BeyondCompare ToolKind = "BeyondCompare"
	//P4MergeText diff tool
	P4MergeText ToolKind = "P4MergeText"
	//P4MergeImage diff tool
	P4MergeImage ToolKind = "P4MergeImage"
	//AraxisMerge diff tool
	AraxisMerge ToolKind = "AraxisMerge"
	//Meld diff tool
	Meld ToolKind = "Meld"
	//SublimeMerge diff tool
	SublimeMerge ToolKind = "SublimeMerge"
	//Kaleidoscope diff tool
	Kaleidoscope ToolKind = "Kaleidoscope"
	//CodeCompare diff tool
	CodeCompare ToolKind = "CodeCompare"
	//DeltaWalker diff tool
	DeltaWalker ToolKind = "DeltaWalker"
	//WinMerge diff tool
	WinMerge ToolKind = "WinMerge"
	//DiffMerge diff tool
	DiffMerge ToolKind = "DiffMerge"
	//TortoiseMerge diff tool
	TortoiseMerge ToolKind = "TortoiseMerge"
	//TortoiseGitMerge diff tool
	TortoiseGitMerge ToolKind = "TortoiseGitMerge"
	//TortoiseIDiff diff tool
	TortoiseIDiff ToolKind = "TortoiseIDiff"
	//KDiff3 diff tool
	KDiff3 ToolKind = "KDiff3"
	//TkDiff diff tool
	TkDiff ToolKind = "TkDiff"
	//Guiffy diff tool
	Guiffy ToolKind = "Guiffy"
	//ExamDiff diff tool
	ExamDiff ToolKind = "ExamDiff"
	//Diffinity diff tool
	Diffinity ToolKind = "Diffinity"
	//VisualStudioCode diff tool
	VisualStudioCode ToolKind = "VisualStudioCode"
	//GoLand diff tool
	GoLand ToolKind = "GoLand"
	//Vim diff tool
	Vim ToolKind = "Vim"
	//Neovim diff tool
	Neovim ToolKind = "Neovim"
)

type Tools

type Tools struct {
	// contains filtered or unexported fields
}

func NewTools

func NewTools() *Tools

NewTools creates a new diff tool accessor

func (*Tools) AddResolvedToolAtStart

func (t *Tools) AddResolvedToolAtStart(tool *ResolvedTool)

func (*Tools) AddTool

func (t *Tools) AddTool(name string, autoRefresh bool, isMdi bool, supportsText bool, requiresTarget bool,
	targetLeftArguments BuildArguments, targetRightArguments BuildArguments,
	exePath string, binaryExtensions []string) (*ResolvedTool, bool)

func (*Tools) TryFind

func (t *Tools) TryFind(kind ToolKind) (tool *ResolvedTool, found bool)

TryFind finds a tool by the provided kind

func (*Tools) TryFindByPath

func (t *Tools) TryFindByPath(path string) (tool *ResolvedTool, found bool)

TryFindByPath finds a tool by the provided path

func (*Tools) TryFindForExtension

func (t *Tools) TryFindForExtension(extension string) (tool *ResolvedTool, found bool)

TryFindForExtension finds a tool based on the provided extension

type TryResolveTool

type TryResolveTool func() (resolved *ResolvedTool, found bool)

TryResolveTool a function that possibly finds a diff tool

Jump to

Keyboard shortcuts

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