diff options
author | James Moger <james.moger@gitblit.com> | 2012-09-29 23:40:46 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2012-09-29 23:40:46 -0400 |
commit | 1e1b85270f93b3bca624c99b478f3a9a23be2395 (patch) | |
tree | 8dfcbd8ca4813d2a42455c62cae3b433d8c0c28a /src/com/gitblit/utils/StringUtils.java | |
parent | 0d531b187e123dea5e83b5b7d4749478f26254c1 (diff) | |
download | gitblit-1e1b85270f93b3bca624c99b478f3a9a23be2395.tar.gz gitblit-1e1b85270f93b3bca624c99b478f3a9a23be2395.zip |
Preliminary implementation of server-side forking (issue 137)
The fork mechanism clones the repository , access restrictions, and
other config options. The app has been updated throughout to handle
personal repositories and to properly display origin/fork links.
In order to fork a repository the user account must have the #fork role,
the origin repository must permit forking, and the user account must
have standard clone permissions to the repository.
Because forking introduces a new user role no existing user accounts can
automatically begin forking a repository. This is both a pro and a con.
Since the fork has the same access restrictions as the origin repository,
those who can access the origin may also access the fork. This is intentional
to facilitate integration-manager workflow. The fork owner does have the
power to completely change the access restrictions of his/her fork.
Diffstat (limited to 'src/com/gitblit/utils/StringUtils.java')
-rw-r--r-- | src/com/gitblit/utils/StringUtils.java | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/com/gitblit/utils/StringUtils.java b/src/com/gitblit/utils/StringUtils.java index e4407901..07113388 100644 --- a/src/com/gitblit/utils/StringUtils.java +++ b/src/com/gitblit/utils/StringUtils.java @@ -367,7 +367,7 @@ public class StringUtils { * @return the first invalid character found or null if string is acceptable
*/
public static Character findInvalidCharacter(String name) {
- char[] validChars = { '/', '.', '_', '-' };
+ char[] validChars = { '/', '.', '_', '-', '~' };
for (char c : name.toCharArray()) {
if (!Character.isLetterOrDigit(c)) {
boolean ok = false;
@@ -660,4 +660,31 @@ public class StringUtils { }
return input;
}
+
+ /**
+ * Returns the first path element of a path string. If no path separator is
+ * found in the path, an empty string is returned.
+ *
+ * @param path
+ * @return the first element in the path
+ */
+ public static String getFirstPathElement(String path) {
+ if (path.indexOf('/') > -1) {
+ return path.substring(0, path.indexOf('/')).trim();
+ }
+ return "";
+ }
+
+ /**
+ * Returns the last path element of a path string
+ *
+ * @param path
+ * @return the last element in the path
+ */
+ public static String getLastPathElement(String path) {
+ if (path.indexOf('/') > -1) {
+ return path.substring(path.lastIndexOf('/') + 1);
+ }
+ return path;
+ }
}
\ No newline at end of file |