|
|
@ -193,12 +193,12 @@ func Diff(ctx *middleware.Context) { |
|
|
|
|
|
|
|
|
|
|
|
userName := ctx.Repo.Owner.Name |
|
|
|
userName := ctx.Repo.Owner.Name |
|
|
|
repoName := ctx.Repo.Repository.Name |
|
|
|
repoName := ctx.Repo.Repository.Name |
|
|
|
commitId := ctx.Repo.CommitId |
|
|
|
commitID := ctx.Repo.CommitID |
|
|
|
|
|
|
|
|
|
|
|
commit := ctx.Repo.Commit |
|
|
|
commit := ctx.Repo.Commit |
|
|
|
commit.CommitMessage = commit.CommitMessage |
|
|
|
commit.CommitMessage = commit.CommitMessage |
|
|
|
diff, err := models.GetDiffCommit(models.RepoPath(userName, repoName), |
|
|
|
diff, err := models.GetDiffCommit(models.RepoPath(userName, repoName), |
|
|
|
commitId, setting.Git.MaxGitDiffLines) |
|
|
|
commitID, setting.Git.MaxGitDiffLines) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.Handle(404, "GetDiffCommit", err) |
|
|
|
ctx.Handle(404, "GetDiffCommit", err) |
|
|
|
return |
|
|
|
return |
|
|
@ -236,17 +236,17 @@ func Diff(ctx *middleware.Context) { |
|
|
|
ctx.Data["Username"] = userName |
|
|
|
ctx.Data["Username"] = userName |
|
|
|
ctx.Data["Reponame"] = repoName |
|
|
|
ctx.Data["Reponame"] = repoName |
|
|
|
ctx.Data["IsImageFile"] = isImageFile |
|
|
|
ctx.Data["IsImageFile"] = isImageFile |
|
|
|
ctx.Data["Title"] = commit.Summary() + " · " + base.ShortSha(commitId) |
|
|
|
ctx.Data["Title"] = commit.Summary() + " · " + base.ShortSha(commitID) |
|
|
|
ctx.Data["Commit"] = commit |
|
|
|
ctx.Data["Commit"] = commit |
|
|
|
ctx.Data["Author"] = models.ValidateCommitWithEmail(commit) |
|
|
|
ctx.Data["Author"] = models.ValidateCommitWithEmail(commit) |
|
|
|
ctx.Data["Diff"] = diff |
|
|
|
ctx.Data["Diff"] = diff |
|
|
|
ctx.Data["Parents"] = parents |
|
|
|
ctx.Data["Parents"] = parents |
|
|
|
ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0 |
|
|
|
ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0 |
|
|
|
ctx.Data["SourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", commitId) |
|
|
|
ctx.Data["SourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", commitID) |
|
|
|
if commit.ParentCount() > 0 { |
|
|
|
if commit.ParentCount() > 0 { |
|
|
|
ctx.Data["BeforeSourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", parents[0]) |
|
|
|
ctx.Data["BeforeSourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", parents[0]) |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.Data["RawPath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "raw", commitId) |
|
|
|
ctx.Data["RawPath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "raw", commitID) |
|
|
|
ctx.HTML(200, DIFF) |
|
|
|
ctx.HTML(200, DIFF) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -255,17 +255,17 @@ func CompareDiff(ctx *middleware.Context) { |
|
|
|
ctx.Data["IsDiffCompare"] = true |
|
|
|
ctx.Data["IsDiffCompare"] = true |
|
|
|
userName := ctx.Repo.Owner.Name |
|
|
|
userName := ctx.Repo.Owner.Name |
|
|
|
repoName := ctx.Repo.Repository.Name |
|
|
|
repoName := ctx.Repo.Repository.Name |
|
|
|
beforeCommitId := ctx.Params(":before") |
|
|
|
beforeCommitID := ctx.Params(":before") |
|
|
|
afterCommitId := ctx.Params(":after") |
|
|
|
afterCommitID := ctx.Params(":after") |
|
|
|
|
|
|
|
|
|
|
|
commit, err := ctx.Repo.GitRepo.GetCommit(afterCommitId) |
|
|
|
commit, err := ctx.Repo.GitRepo.GetCommit(afterCommitID) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.Handle(404, "GetCommit", err) |
|
|
|
ctx.Handle(404, "GetCommit", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
diff, err := models.GetDiffRange(models.RepoPath(userName, repoName), beforeCommitId, |
|
|
|
diff, err := models.GetDiffRange(models.RepoPath(userName, repoName), beforeCommitID, |
|
|
|
afterCommitId, setting.Git.MaxGitDiffLines) |
|
|
|
afterCommitID, setting.Git.MaxGitDiffLines) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.Handle(404, "GetDiffRange", err) |
|
|
|
ctx.Handle(404, "GetDiffRange", err) |
|
|
|
return |
|
|
|
return |
|
|
@ -290,7 +290,7 @@ func CompareDiff(ctx *middleware.Context) { |
|
|
|
return isImage |
|
|
|
return isImage |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
commits, err := commit.CommitsBeforeUntil(beforeCommitId) |
|
|
|
commits, err := commit.CommitsBeforeUntil(beforeCommitID) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.Handle(500, "CommitsBeforeUntil", err) |
|
|
|
ctx.Handle(500, "CommitsBeforeUntil", err) |
|
|
|
return |
|
|
|
return |
|
|
@ -299,17 +299,17 @@ func CompareDiff(ctx *middleware.Context) { |
|
|
|
|
|
|
|
|
|
|
|
ctx.Data["Commits"] = commits |
|
|
|
ctx.Data["Commits"] = commits |
|
|
|
ctx.Data["CommitCount"] = commits.Len() |
|
|
|
ctx.Data["CommitCount"] = commits.Len() |
|
|
|
ctx.Data["BeforeCommitId"] = beforeCommitId |
|
|
|
ctx.Data["BeforeCommitID"] = beforeCommitID |
|
|
|
ctx.Data["AfterCommitId"] = afterCommitId |
|
|
|
ctx.Data["AfterCommitID"] = afterCommitID |
|
|
|
ctx.Data["Username"] = userName |
|
|
|
ctx.Data["Username"] = userName |
|
|
|
ctx.Data["Reponame"] = repoName |
|
|
|
ctx.Data["Reponame"] = repoName |
|
|
|
ctx.Data["IsImageFile"] = isImageFile |
|
|
|
ctx.Data["IsImageFile"] = isImageFile |
|
|
|
ctx.Data["Title"] = "Comparing " + base.ShortSha(beforeCommitId) + "..." + base.ShortSha(afterCommitId) + " · " + userName + "/" + repoName |
|
|
|
ctx.Data["Title"] = "Comparing " + base.ShortSha(beforeCommitID) + "..." + base.ShortSha(afterCommitID) + " · " + userName + "/" + repoName |
|
|
|
ctx.Data["Commit"] = commit |
|
|
|
ctx.Data["Commit"] = commit |
|
|
|
ctx.Data["Diff"] = diff |
|
|
|
ctx.Data["Diff"] = diff |
|
|
|
ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0 |
|
|
|
ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0 |
|
|
|
ctx.Data["SourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", afterCommitId) |
|
|
|
ctx.Data["SourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", afterCommitID) |
|
|
|
ctx.Data["BeforeSourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", beforeCommitId) |
|
|
|
ctx.Data["BeforeSourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", beforeCommitID) |
|
|
|
ctx.Data["RawPath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "raw", afterCommitId) |
|
|
|
ctx.Data["RawPath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "raw", afterCommitID) |
|
|
|
ctx.HTML(200, DIFF) |
|
|
|
ctx.HTML(200, DIFF) |
|
|
|
} |
|
|
|
} |
|
|
|