| | |
| | | import org.eclipse.jgit.lib.Repository;
|
| | | import org.eclipse.jgit.revwalk.RevCommit;
|
| | |
|
| | | import com.gitblit.GitBlit;
|
| | | import com.gitblit.utils.JGitUtils;
|
| | | import com.gitblit.wicket.GitBlitWebApp;
|
| | | import com.gitblit.utils.StringUtils;
|
| | | import com.gitblit.wicket.WicketUtils;
|
| | |
|
| | |
|
| | | public class PatchPage extends WebPage {
|
| | |
|
| | |
| | | redirectToInterceptPage(new RepositoriesPage());
|
| | | }
|
| | | final String repositoryName = WicketUtils.getRepositoryName(params);
|
| | | final String objectId = WicketUtils.getObject(params); |
| | | final String baseObjectId = WicketUtils.getBaseObjectId(params);
|
| | | final String objectId = WicketUtils.getObject(params);
|
| | | final String blobPath = WicketUtils.getPath(params);
|
| | |
|
| | | ServletWebRequest servletWebRequest = (ServletWebRequest) getRequest();
|
| | | HttpServletRequest req = servletWebRequest.getHttpServletRequest();
|
| | | req.getServerName();
|
| | |
|
| | | Repository r = GitBlitWebApp.get().getRepository(req, repositoryName);
|
| | | Repository r = GitBlit.self().getRepository(req, repositoryName);
|
| | | if (r == null) {
|
| | | error("Can not load repository " + repositoryName);
|
| | | redirectToInterceptPage(new RepositoriesPage());
|
| | |
| | | }
|
| | |
|
| | | RevCommit commit = JGitUtils.getCommit(r, objectId);
|
| | | String patch = JGitUtils.getCommitPatch(r, commit, blobPath);
|
| | | String patch;
|
| | | if (StringUtils.isEmpty(baseObjectId)) {
|
| | | patch = JGitUtils.getCommitPatch(r, commit, blobPath);
|
| | | } else {
|
| | | RevCommit baseCommit = JGitUtils.getCommit(r, baseObjectId);
|
| | | patch = JGitUtils.getCommitPatch(r, baseCommit, commit, blobPath); |
| | | }
|
| | | add(new Label("patchText", patch));
|
| | | r.close();
|
| | | } |
| | | }
|
| | | }
|