blob: 7eb6955f30703a1090c06e504d231e212396ddf2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
// Copyright (C) 2009 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.common.data;
/** Class to store information about different gitweb types. */
public class GitWebType {
/**
* Get a GitWebType based on the given name.
*
* @param name Name to look for.
* @return GitWebType from the given name, else null if not found.
*/
public static GitWebType fromName(final String name) {
final GitWebType type;
if (name == null || name.isEmpty() || name.equalsIgnoreCase("gitweb")) {
type = new GitWebType();
type.setProject("?p=${project}.git;a=summary");
type.setRevision("?p=${project}.git;a=commit;h=${commit}");
type.setBranch("?p=${project}.git;a=shortlog;h=${branch}");
} else if (name.equalsIgnoreCase("cgit")) {
type = new GitWebType();
type.setProject("${project}/summary");
type.setRevision("${project}/commit/?id=${commit}");
type.setBranch("${project}/log/?h=${branch}");
} else if (name.equalsIgnoreCase("custom")) {
type = new GitWebType();
} else {
type = null;
}
return type;
}
/** String for revision view url. */
private String revision;
/** ParamertizedString for project view url. */
private String project;
/** ParamertizedString for branch view url. */
private String branch;
/** Private default constructor for gson. */
protected GitWebType() {
}
/**
* Get the String for branch view.
*
* @return The String for branch view
*/
public String getBranch() {
return branch;
}
/**
* Get the String for project view.
*
* @return The String for project view
*/
public String getProject() {
return project;
}
/**
* Get the String for revision view.
*
* @return The String for revision view
*/
public String getRevision() {
return revision;
}
/**
* Set the pattern for branch view.
*
* @param pattern The pattern for branch view
*/
public void setBranch(final String pattern) {
if (pattern != null && !pattern.isEmpty()) {
branch = pattern;
}
}
/**
* Set the pattern for project view.
*
* @param pattern The pattern for project view
*/
public void setProject(final String pattern) {
if (pattern != null && !pattern.isEmpty()) {
project = pattern;
}
}
/**
* Set the pattern for revision view.
*
* @param pattern The pattern for revision view
*/
public void setRevision(final String pattern) {
if (pattern != null && !pattern.isEmpty()) {
revision = pattern;
}
}
}
|