Skip to content

Commit 3faa3c6

Browse files
committed
remove AfterCommit & BeforeCommit from DiffOptions
1 parent d212c47 commit 3faa3c6

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

routers/web/repo/pull.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,6 @@ func viewPullFiles(ctx *context.Context, specifiedStartCommit, specifiedEndCommi
753753

754754
diffOptions := &gitdiff.DiffOptions{
755755
AfterCommitID: endCommitID,
756-
AfterCommit: commit,
757756
SkipTo: ctx.FormString("skip-to"),
758757
MaxLines: maxLines,
759758
MaxLineCharacters: setting.Git.MaxGitDiffLineCharacters,
@@ -764,7 +763,6 @@ func viewPullFiles(ctx *context.Context, specifiedStartCommit, specifiedEndCommi
764763

765764
if !willShowSpecifiedCommit {
766765
diffOptions.BeforeCommitID = startCommitID
767-
diffOptions.BeforeCommit = baseCommit
768766
}
769767

770768
var methodWithError string

services/gitdiff/gitdiff.go

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,9 +1082,7 @@ func readFileName(rd *strings.Reader) (string, bool) {
10821082
// DiffOptions represents the options for a DiffRange
10831083
type 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 {
11001098
func 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

Comments
 (0)