@@ -1082,9 +1082,7 @@ func readFileName(rd *strings.Reader) (string, bool) {
10821082// DiffOptions represents the options for a DiffRange
10831083type DiffOptions struct {
10841084 BeforeCommitID string
1085- BeforeCommit * git.Commit
10861085 AfterCommitID string
1087- AfterCommit * git.Commit
10881086 SkipTo string
10891087 MaxLines int
10901088 MaxLineCharacters int
@@ -1100,13 +1098,10 @@ type DiffOptions struct {
11001098func GetDiff (ctx context.Context , gitRepo * git.Repository , opts * DiffOptions , files ... string ) (* Diff , error ) {
11011099 repoPath := gitRepo .Path
11021100
1103- commit := opts .AfterCommit
1104- if commit == nil {
1105- var err error
1106- commit , err = gitRepo .GetCommit (opts .AfterCommitID )
1107- if err != nil {
1108- return nil , err
1109- }
1101+ var beforeCommit * git.Commit
1102+ commit , err := gitRepo .GetCommit (opts .AfterCommitID )
1103+ if err != nil {
1104+ return nil , err
11101105 }
11111106
11121107 ctx , cancel := context .WithCancel (ctx )
@@ -1135,12 +1130,10 @@ func GetDiff(ctx context.Context, gitRepo *git.Repository, opts *DiffOptions, fi
11351130 AddDynamicArguments (actualBeforeCommitID , opts .AfterCommitID )
11361131 opts .BeforeCommitID = actualBeforeCommitID
11371132
1138- if opts .BeforeCommit == nil {
1139- var err error
1140- opts .BeforeCommit , err = gitRepo .GetCommit (opts .BeforeCommitID )
1141- if err != nil {
1142- return nil , err
1143- }
1133+ var err error
1134+ beforeCommit , err = gitRepo .GetCommit (opts .BeforeCommitID )
1135+ if err != nil {
1136+ return nil , err
11441137 }
11451138 }
11461139
@@ -1213,7 +1206,7 @@ func GetDiff(ctx context.Context, gitRepo *git.Repository, opts *DiffOptions, fi
12131206 }
12141207 diffFile .IsGenerated = isGenerated .Value ()
12151208
1216- tailSection := diffFile .GetTailSection (gitRepo , opts . BeforeCommit , commit )
1209+ tailSection := diffFile .GetTailSection (gitRepo , beforeCommit , commit )
12171210 if tailSection != nil {
12181211 diffFile .Sections = append (diffFile .Sections , tailSection )
12191212 }
0 commit comments