| | |
| | | import com.gitblit.utils.JGitUtils.LastChange; |
| | | import com.gitblit.utils.JsonUtils; |
| | | import com.gitblit.utils.MetricUtils; |
| | | import com.gitblit.utils.ModelUtils; |
| | | import com.gitblit.utils.ObjectCache; |
| | | import com.gitblit.utils.StringUtils; |
| | | import com.gitblit.utils.TimeUtils; |
| | |
| | | // personal repository |
| | | model.addOwner(user.username); |
| | | String oldRepositoryName = model.name; |
| | | model.name = "~" + user.username + model.name.substring(model.projectPath.length()); |
| | | model.projectPath = "~" + user.username; |
| | | model.name = user.getPersonalPath() + model.name.substring(model.projectPath.length()); |
| | | model.projectPath = user.getPersonalPath(); |
| | | updateRepositoryModel(oldRepositoryName, model, false); |
| | | } else if (model.isOwner(username)) { |
| | | // common/shared repo |
| | |
| | | ProjectModel project = configs.get(name.toLowerCase()); |
| | | if (project == null) { |
| | | project = new ProjectModel(name); |
| | | if (name.length() > 0 && name.charAt(0) == '~') { |
| | | UserModel user = getUserModel(name.substring(1)); |
| | | if (ModelUtils.isPersonalRepository(name)) { |
| | | UserModel user = getUserModel(ModelUtils.getUserNameFromRepoPath(name)); |
| | | if (user != null) { |
| | | project.title = user.getDisplayName(); |
| | | project.description = "personal repositories"; |
| | |
| | | boolean hasOrigin = !StringUtils.isEmpty(config.getString("remote", "origin", "url")); |
| | | |
| | | if (config != null) { |
| | | // Initialize description from description file |
| | | if (getConfig(config,"description", null) == null) { |
| | | File descFile = new File(r.getDirectory(), "description"); |
| | | if (descFile.exists()) { |
| | | config.setString(Constants.CONFIG_GITBLIT, null, "description", |
| | | com.gitblit.utils.FileUtils.readContent(descFile, System.getProperty("line.separator"))); |
| | | } |
| | | } |
| | | model.description = getConfig(config, "description", ""); |
| | | model.originRepository = getConfig(config, "originRepository", null); |
| | | model.addOwners(ArrayUtils.fromString(getConfig(config, "owner", ""))); |
| | |
| | | * @return the name of the user's fork, null otherwise |
| | | */ |
| | | public String getFork(String username, String origin) { |
| | | String userProject = "~" + username.toLowerCase(); |
| | | String userProject = ModelUtils.getPersonalPath(username); |
| | | if (settings.getBoolean(Keys.git.cacheRepositoryList, true)) { |
| | | String userPath = userProject + "/"; |
| | | |
| | |
| | | // update settings |
| | | if (r != null) { |
| | | updateConfiguration(r, repository); |
| | | // Update the description file |
| | | File descFile = new File(r.getDirectory(), "description"); |
| | | if (repository.description != null) |
| | | { |
| | | com.gitblit.utils.FileUtils.writeContent(descFile, repository.description); |
| | | } |
| | | else if (descFile.exists() && !descFile.isDirectory()) { |
| | | descFile.delete(); |
| | | } |
| | | // only update symbolic head if it changes |
| | | String currentRef = JGitUtils.getHEADRef(r); |
| | | if (!StringUtils.isEmpty(repository.HEAD) && !repository.HEAD.equals(currentRef)) { |
| | |
| | | * @throws GitBlitException |
| | | */ |
| | | public RepositoryModel fork(RepositoryModel repository, UserModel user) throws GitBlitException { |
| | | String cloneName = MessageFormat.format("~{0}/{1}.git", user.username, StringUtils.stripDotGit(StringUtils.getLastPathElement(repository.name))); |
| | | String cloneName = MessageFormat.format("{0}/{1}.git", user.getPersonalPath(), StringUtils.stripDotGit(StringUtils.getLastPathElement(repository.name))); |
| | | String fromUrl = MessageFormat.format("file://{0}/{1}", repositoriesFolder.getAbsolutePath(), repository.name); |
| | | |
| | | // clone the repository |