2021-06-05 07:08:36 +02:00
|
|
|
package diffing
|
|
|
|
|
|
|
|
// if ref is blank we're not diffing anything
|
|
|
|
type Diffing struct {
|
|
|
|
Ref string
|
|
|
|
Reverse bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func New() Diffing {
|
|
|
|
return Diffing{}
|
|
|
|
}
|
|
|
|
|
2022-02-22 11:13:11 +02:00
|
|
|
func (self *Diffing) Active() bool {
|
|
|
|
return self.Ref != ""
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetFromAndReverseArgsForDiff tells us the from and reverse args to be used in a diff command.
|
|
|
|
// If we're not in diff mode we'll end up with the equivalent of a `git show` i.e `git diff blah^..blah`.
|
2022-03-26 15:18:08 +02:00
|
|
|
func (self *Diffing) GetFromAndReverseArgsForDiff(from string) (string, bool) {
|
2022-02-22 11:13:11 +02:00
|
|
|
reverse := false
|
|
|
|
|
|
|
|
if self.Active() {
|
|
|
|
reverse = self.Reverse
|
|
|
|
from = self.Ref
|
|
|
|
}
|
|
|
|
|
|
|
|
return from, reverse
|
2021-06-05 07:08:36 +02:00
|
|
|
}
|