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 |
*/
|
5fe7df
|
16 |
package com.gitblit.wicket.pages;
|
JM |
17 |
|
4ab184
|
18 |
import java.text.MessageFormat;
|
JM |
19 |
import java.util.Arrays;
|
e11f48
|
20 |
import java.util.Date;
|
608ece
|
21 |
import java.util.List;
|
JM |
22 |
|
5fe7df
|
23 |
import org.apache.wicket.PageParameters;
|
4ab184
|
24 |
import org.apache.wicket.markup.html.basic.Label;
|
JM |
25 |
import org.eclipse.jgit.lib.Constants;
|
5fe7df
|
26 |
import org.eclipse.jgit.lib.Repository;
|
JM |
27 |
|
1f9dae
|
28 |
import com.gitblit.models.RefModel;
|
5fe7df
|
29 |
import com.gitblit.utils.JGitUtils;
|
bc10f9
|
30 |
import com.gitblit.wicket.WicketUtils;
|
01eec5
|
31 |
import com.gitblit.wicket.panels.GravatarImage;
|
1f9dae
|
32 |
import com.gitblit.wicket.panels.LinkPanel;
|
4ab184
|
33 |
import com.gitblit.wicket.panels.RefsPanel;
|
5fe7df
|
34 |
|
JM |
35 |
public class TagPage extends RepositoryPage {
|
|
36 |
|
|
37 |
public TagPage(PageParameters params) {
|
cebf45
|
38 |
super(params);
|
5fe7df
|
39 |
|
155bf7
|
40 |
Repository r = getRepository();
|
JM |
41 |
|
4ab184
|
42 |
// Find tag in repository
|
5cc4f2
|
43 |
List<RefModel> tags = JGitUtils.getTags(r, true, -1);
|
9ab5cc
|
44 |
RefModel tagRef = null;
|
155bf7
|
45 |
for (RefModel tag : tags) {
|
9ab5cc
|
46 |
if (tag.getName().equals(objectId) || tag.getObjectId().getName().equals(objectId)) {
|
JM |
47 |
tagRef = tag;
|
|
48 |
break;
|
608ece
|
49 |
}
|
JM |
50 |
}
|
5fe7df
|
51 |
|
4ab184
|
52 |
// Failed to find tag!
|
9ab5cc
|
53 |
if (tagRef == null) {
|
6caa93
|
54 |
error(MessageFormat.format(getString("gb.couldNotFindTag"), objectId), true);
|
155bf7
|
55 |
}
|
JM |
56 |
|
4ab184
|
57 |
// Display tag.
|
JM |
58 |
Class<? extends RepositoryPage> linkClass;
|
|
59 |
PageParameters linkParameters = newCommitParameter(tagRef.getReferencedObjectId().getName());
|
|
60 |
String typeKey;
|
|
61 |
switch (tagRef.getReferencedObjectType()) {
|
|
62 |
case Constants.OBJ_BLOB:
|
|
63 |
typeKey = "gb.blob";
|
|
64 |
linkClass = BlobPage.class;
|
|
65 |
break;
|
|
66 |
case Constants.OBJ_TREE:
|
|
67 |
typeKey = "gb.tree";
|
|
68 |
linkClass = TreePage.class;
|
|
69 |
break;
|
|
70 |
case Constants.OBJ_COMMIT:
|
|
71 |
default:
|
|
72 |
typeKey = "gb.commit";
|
|
73 |
linkClass = CommitPage.class;
|
|
74 |
break;
|
|
75 |
}
|
|
76 |
add(new LinkPanel("commit", "title", tagRef.displayName, linkClass, linkParameters));
|
01eec5
|
77 |
add(new GravatarImage("taggerAvatar", tagRef.getAuthorIdent()));
|
JM |
78 |
|
4ab184
|
79 |
add(new RefsPanel("tagName", repositoryName, Arrays.asList(tagRef)));
|
JM |
80 |
add(new Label("tagId", tagRef.getObjectId().getName()));
|
|
81 |
add(new LinkPanel("taggedObject", "list", tagRef.getReferencedObjectId().getName(),
|
|
82 |
linkClass, linkParameters));
|
|
83 |
add(new Label("taggedObjectType", getString(typeKey)));
|
5fe7df
|
84 |
|
33d8d8
|
85 |
add(createPersonPanel("tagger", tagRef.getAuthorIdent(), com.gitblit.Constants.SearchType.AUTHOR));
|
e11f48
|
86 |
Date when = new Date(0);
|
JM |
87 |
if (tagRef.getAuthorIdent() != null) {
|
|
88 |
when = tagRef.getAuthorIdent().getWhen();
|
|
89 |
}
|
9adf62
|
90 |
add(WicketUtils.createTimestampLabel("tagDate", when, getTimeZone(), getTimeUtils()));
|
4ab184
|
91 |
|
JM |
92 |
addFullText("fullMessage", tagRef.getFullMessage(), true);
|
5fe7df
|
93 |
}
|
155bf7
|
94 |
|
cebf45
|
95 |
@Override
|
JM |
96 |
protected String getPageName() {
|
1e47ab
|
97 |
return getString("gb.tag");
|
cebf45
|
98 |
}
|
5fe7df
|
99 |
}
|