commit | author | age
|
f13c4c
|
1 |
/*
|
JM |
2 |
* Copyright 2011 gitblit.com.
|
|
3 |
*
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
6 |
* You may obtain a copy of the License at
|
|
7 |
*
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9 |
*
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13 |
* See the License for the specific language governing permissions and
|
|
14 |
* limitations under the License.
|
|
15 |
*/
|
608ece
|
16 |
package com.gitblit.wicket.pages;
|
JM |
17 |
|
|
18 |
import org.apache.wicket.PageParameters;
|
|
19 |
import org.apache.wicket.markup.html.basic.Label;
|
|
20 |
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
|
|
21 |
import org.eclipse.jgit.lib.Repository;
|
|
22 |
import org.eclipse.jgit.revwalk.RevCommit;
|
|
23 |
|
3df349
|
24 |
import com.gitblit.GitBlit;
|
JM |
25 |
import com.gitblit.Keys;
|
1f9dae
|
26 |
import com.gitblit.utils.DiffUtils;
|
a125cf
|
27 |
import com.gitblit.utils.DiffUtils.DiffOutputType;
|
608ece
|
28 |
import com.gitblit.utils.JGitUtils;
|
f5d0ad
|
29 |
import com.gitblit.utils.StringUtils;
|
608ece
|
30 |
import com.gitblit.wicket.WicketUtils;
|
c1c3c6
|
31 |
import com.gitblit.wicket.panels.CommitHeaderPanel;
|
608ece
|
32 |
import com.gitblit.wicket.panels.PathBreadcrumbsPanel;
|
JM |
33 |
|
|
34 |
public class BlobDiffPage extends RepositoryPage {
|
|
35 |
|
|
36 |
public BlobDiffPage(PageParameters params) {
|
|
37 |
super(params);
|
|
38 |
|
|
39 |
final String blobPath = WicketUtils.getPath(params);
|
f1dfc2
|
40 |
final String baseObjectId = WicketUtils.getBaseObjectId(params);
|
608ece
|
41 |
|
JM |
42 |
Repository r = getRepository();
|
bc9d4a
|
43 |
RevCommit commit = getCommit();
|
2a7306
|
44 |
|
JM |
45 |
DiffOutputType diffType = DiffOutputType.forName(GitBlit.getString(Keys.web.diffStyle,
|
|
46 |
DiffOutputType.GITBLIT.name()));
|
3df349
|
47 |
|
f1dfc2
|
48 |
String diff;
|
JM |
49 |
if (StringUtils.isEmpty(baseObjectId)) {
|
|
50 |
// use first parent
|
db653a
|
51 |
diff = DiffUtils.getDiff(r, commit, blobPath, diffType);
|
2a7306
|
52 |
add(new BookmarkablePageLink<Void>("patchLink", PatchPage.class,
|
JM |
53 |
WicketUtils.newPathParameter(repositoryName, objectId, blobPath)));
|
f1dfc2
|
54 |
} else {
|
JM |
55 |
// base commit specified
|
|
56 |
RevCommit baseCommit = JGitUtils.getCommit(r, baseObjectId);
|
db653a
|
57 |
diff = DiffUtils.getDiff(r, baseCommit, commit, blobPath, diffType);
|
2a7306
|
58 |
add(new BookmarkablePageLink<Void>("patchLink", PatchPage.class,
|
JM |
59 |
WicketUtils.newBlobDiffParameter(repositoryName, baseObjectId, objectId,
|
|
60 |
blobPath)));
|
f1dfc2
|
61 |
}
|
2a7306
|
62 |
|
JM |
63 |
add(new BookmarkablePageLink<Void>("commitLink", CommitPage.class,
|
|
64 |
WicketUtils.newObjectParameter(repositoryName, objectId)));
|
|
65 |
add(new BookmarkablePageLink<Void>("commitDiffLink", CommitDiffPage.class,
|
|
66 |
WicketUtils.newObjectParameter(repositoryName, objectId)));
|
608ece
|
67 |
|
JM |
68 |
// diff page links
|
716745
|
69 |
add(new BookmarkablePageLink<Void>("blameLink", BlamePage.class,
|
JM |
70 |
WicketUtils.newPathParameter(repositoryName, objectId, blobPath)));
|
2a7306
|
71 |
add(new BookmarkablePageLink<Void>("historyLink", HistoryPage.class,
|
JM |
72 |
WicketUtils.newPathParameter(repositoryName, objectId, blobPath)));
|
608ece
|
73 |
|
c1c3c6
|
74 |
add(new CommitHeaderPanel("commitHeader", repositoryName, commit));
|
608ece
|
75 |
|
JM |
76 |
add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, blobPath, objectId));
|
155bf7
|
77 |
|
608ece
|
78 |
add(new Label("diffText", diff).setEscapeModelStrings(false));
|
JM |
79 |
}
|
155bf7
|
80 |
|
608ece
|
81 |
@Override
|
JM |
82 |
protected String getPageName() {
|
|
83 |
return getString("gb.diff");
|
|
84 |
}
|
|
85 |
}
|