/** * Creates a link to the file diff. * <p/> * https://SERVER/PATH/projects/PROJECT/repository/revisions/a9182a07750c9a0dfd89a8461adf72ef5ef0885b/diff/pom.xml * <p/> * Returns a diff link for {@link EditType#DELETE} and {@link EditType#EDIT}, for {@link EditType#ADD} returns an * {@link RedmineWeb#getFileLink(Path)}. * * @param path affected file path * @return diff link * @throws IOException */ @Override public URL getDiffLink(Path path) throws IOException { final GitChangeSet changeSet = path.getChangeSet(); final URL changeSetLink = new URL(url, "revisions/" + changeSet.getId().toString()); final URL difflink; if (path.getEditType().equals(EditType.ADD)) { difflink = getFileLink(path); } else { difflink = new URL(changeSetLink, changeSetLink.getPath() + "/diff/" + path.getPath()); } return difflink; }
@Override public URL getFileLink(Path path) throws IOException { if (path.getEditType() == EditType.DELETE) { String spec = buildCommitDiffSpec(path); return new URL(url, url.getPath() + spec); } String spec = param().add("p=" + projectName).add("a=viewblob").add("h=" + path.getDst()).add("f=" + path.getPath()).toString(); return new URL(url, url.getPath() + spec); }
String oldPath = renameSplitMatcher.group(1); String newPath = renameSplitMatcher.group(2); this.paths.add(new Path(src, dst, 'D', oldPath, this)); this.paths.add(new Path(src, dst, 'A', newPath, this)); if (copySplitMatcher.matches() && copySplitMatcher.groupCount() >= 2) { String newPath = copySplitMatcher.group(2); this.paths.add(new Path(src, dst, 'A', newPath, this)); this.paths.add(new Path(src, dst, editMode, path, this));
String oldPath = renameSplitMatcher.group(1); String newPath = renameSplitMatcher.group(2); this.paths.add(new Path(src, dst, 'D', oldPath, this)); this.paths.add(new Path(src, dst, 'A', newPath, this)); if (copySplitMatcher.matches() && copySplitMatcher.groupCount() >= 2) { String newPath = copySplitMatcher.group(2); this.paths.add(new Path(src, dst, 'A', newPath, this)); this.paths.add(new Path(src, dst, editMode, path, this));
String oldPath = renameSplitMatcher.group(1); String newPath = renameSplitMatcher.group(2); this.paths.add(new Path(src, dst, 'D', oldPath, this)); this.paths.add(new Path(src, dst, 'A', newPath, this)); if (copySplitMatcher.matches() && copySplitMatcher.groupCount() >= 2) { String newPath = copySplitMatcher.group(2); this.paths.add(new Path(src, dst, 'A', newPath, this)); this.paths.add(new Path(src, dst, editMode, path, this));
static List<Change> getChangesFromGit(GitClient cli, FilePath workspace, String relativeTargetDirectory, String remoteDebian, PersonIdent account) throws InterruptedException { String changelogPath = remoteDebian + "/changelog"; LinkedList<Change> changesSinceLastChangelogModification = new LinkedList<Change>(); LinkedList<Change> changesSinceLastChangelogModificationByPlugin = new LinkedList<Change>(); boolean firstChangelogModificationFound = false; for (ObjectId rev : cli.revListAll()) { List<String> lines = cli.showRevision(rev); GitChangeSet changeSet = new GitChangeSet(lines, true); String email = getAuthorEmailFromGitRevision(lines); Change change = new Change(changeSet.getAuthorName(), changeSet.getMsg()); for (GitChangeSet.Path path : changeSet.getPaths()) { String filePath = workspace.child(relativeTargetDirectory).child(path.getPath()).getRemote(); if (filePath.equals(changelogPath)) { if (changeSet.getAuthorName().equals(account.getName()) & email.equals(account.getEmailAddress())) { return changesSinceLastChangelogModificationByPlugin; } else { firstChangelogModificationFound = true; } } } if (!firstChangelogModificationFound) { changesSinceLastChangelogModification.addFirst(change); } changesSinceLastChangelogModificationByPlugin.addFirst(change); } return changesSinceLastChangelogModification; }
/** * Creates a link to the commit diff. * * v < 3.0: [GitLab URL]/commits/[Hash]#[File path] * v < 8.0: [GitLab URL]/commit/[Hash]#[File path] * else: [GitLab URL]/commit/[Hash]#diff-[index] * * @param path file path used in diff link * @return diff link * @throws IOException on input or output error */ @Override public URL getDiffLink(Path path) throws IOException { final GitChangeSet changeSet = path.getChangeSet(); String filelink = null; if(getVersion() < 8.0) { filelink = "#" + path.getPath(); } else { filelink = "#diff-" + String.valueOf(getIndexOfPath(path)); } return new URL(getUrl(), calculatePrefix() + changeSet.getId() + filelink); }
/** * Creates a link to the file. * v ≤ 4.2: [GitLab URL]tree/[Hash]/[File path] * v < 5.1: [GitLab URL][Hash]/tree/[File path] * else: [GitLab URL]blob/[Hash]/[File path] * * @param path file path used in diff link * @return file link * @throws IOException on input or output error */ @Override public URL getFileLink(Path path) throws IOException { if (path.getEditType().equals(EditType.DELETE)) { return getDiffLink(path); } else { if(getVersion() <= 4.2) { return new URL(getUrl(), "tree/" + path.getChangeSet().getId() + "/" + path.getPath()); } else if(getVersion() < 5.1) { return new URL(getUrl(), path.getChangeSet().getId() + "/tree/" + path.getPath()); } else { return new URL(getUrl(), "blob/" + path.getChangeSet().getId() + "/" + path.getPath()); } } }
/** * Creates a link to the file. * https://[GitLab URL]/a9182a07750c9a0dfd89a8461adf72ef5ef0885b/tree/pom.xml * * @param path * @return file link * @throws IOException */ @Override public URL getFileLink(Path path) throws IOException { if (path.getEditType().equals(EditType.DELETE)) { return getDiffLink(path); } else { String spec; if(getVersion() >= 5.1) { spec = "blob/" + path.getChangeSet().getId() + "/" + path.getPath(); } else { spec = path.getChangeSet().getId() + "/tree/" + path.getPath(); } URL url = getRepoUrl(); return new URL(url, url.getPath() + spec); } }
/** * Creates a link to the file diff. * * https://SERVER/PATH/projects/PROJECT/repository/revisions/a9182a07750c9a0dfd89a8461adf72ef5ef0885b/diff/pom.xml * * Returns a diff link for {@link EditType#DELETE} and {@link EditType#EDIT}, for {@link EditType#ADD} returns an * {@link #getFileLink}. * * * @param path * affected file path * @return diff link * @throws IOException on input or output error */ @Override public URL getDiffLink(Path path) throws IOException { final GitChangeSet changeSet = path.getChangeSet(); URL url = getUrl(); final URL changeSetLink = new URL(url, "revisions/" + changeSet.getId()); final URL difflink; if (path.getEditType().equals(EditType.ADD)) { difflink = getFileLink(path); } else { difflink = new URL(changeSetLink, changeSetLink.getPath() + "/diff/" + path.getPath()); } return difflink; }
/** * Creates a link to the file. * {@code http://[RhodeCode URL]/files/[commit]/[path]} * * @param path affected file path * @return diff link * @throws IOException on input or output error */ @Override public URL getFileLink(Path path) throws IOException { GitChangeSet changeSet = path.getChangeSet(); URL url = getUrl(); if (path.getEditType() == EditType.DELETE) { String parentCommit = changeSet.getParentCommit(); if (parentCommit == null) { parentCommit = "."; } return new URL(url, url.getPath() + "files/" + parentCommit + '/' + path.getPath()); } else { return new URL(url, url.getPath() + "files/" + changeSet.getId() + '/' + path.getPath()); } }
/** * Creates a link to the file diff. * <p/> * https://SERVER/PATH/projects/PROJECT/repository/revisions/a9182a07750c9a0dfd89a8461adf72ef5ef0885b/diff/pom.xml * <p/> * Returns a diff link for {@link EditType#DELETE} and {@link EditType#EDIT}, for {@link EditType#ADD} returns an * {@link RedmineWeb#getFileLink(Path)}. * * @param path affected file path * @return diff link * @throws IOException */ @Override public URL getDiffLink(Path path) throws IOException { final GitChangeSet changeSet = path.getChangeSet(); final URL changeSetLink = new URL(url, "revisions/" + changeSet.getId().toString()); final URL difflink; if (path.getEditType().equals(EditType.ADD)) { difflink = getFileLink(path); } else { difflink = new URL(changeSetLink, changeSetLink.getPath() + "/diff/" + path.getPath()); } return difflink; }
/** * Creates a link to the file diff. * http://[GitWeb URL]?a=blobdiff;f=[path];fp=[path];h=[dst];hp=[src];hb=[commit];hpb=[parent commit] * * @param path affected file path * @return diff link * @throws IOException on input or output error */ @Override public URL getDiffLink(Path path) throws IOException { if (path.getEditType() != EditType.EDIT || path.getSrc() == null || path.getDst() == null || path.getChangeSet().getParentCommit() == null) { return null; } GitChangeSet changeSet = path.getChangeSet(); URL url = getUrl(); String spec = param(url).add("a=blobdiff").add("f=" + path.getPath()).add("fp=" + path.getPath()) .add("h=" + path.getSrc()).add("hp=" + path.getDst()) .add("hb=" + changeSet.getId()).add("hpb=" + changeSet.getParentCommit()).toString(); return new URL(url, url.getPath()+spec); }
/** * Creates a link to the file diff. * http://[GitWeb URL]?a=blobdiff;f=[path];fp=[path];h=[dst];hp=[src];hb=[commit];hpb=[parent commit] * * @param path affected file path * @return diff link * @throws IOException */ @Override public URL getDiffLink(Path path) throws IOException { if (path.getEditType() != EditType.EDIT || path.getSrc() == null || path.getDst() == null || path.getChangeSet().getParentCommit() == null) { return null; } GitChangeSet changeSet = path.getChangeSet(); String spec = param().add("a=blobdiff").add("f=" + path.getPath()).add("fp=" + path.getPath()) .add("h=" + path.getSrc()).add("hp=" + path.getDst()) .add("hb=" + changeSet.getId()).add("hpb=" + changeSet.getParentCommit()).toString(); return new URL(url, url.getPath() + spec); }
/** * Calculate the index of the given path in a * sorted list of affected files * * @param path affected file path * @return The index in the lexicographical sorted filelist * @throws IOException on input or output error */ protected int getIndexOfPath(Path path) throws IOException { final String pathAsString = path.getPath(); final GitChangeSet changeSet = path.getChangeSet(); int i = 0; for (String affected : changeSet.getAffectedPaths()) { if (affected.compareTo(pathAsString) < 0) i++; } return i; }
/** * Creates a link to the file diff. * http://[GitWeb URL]?a=blobdiff;f=[path];fp=[path];h=[dst];hp=[src];hb=[commit];hpb=[parent commit] * * @param path affected file path * @return diff link * @throws IOException */ @Override public URL getDiffLink(Path path) throws IOException { if (path.getEditType() != EditType.EDIT || path.getSrc() == null || path.getDst() == null || path.getChangeSet().getParentCommit() == null) { return null; } GitChangeSet changeSet = path.getChangeSet(); String spec = param().add("a=blobdiff").add("f=" + path.getPath()).add("fp=" + path.getPath()) .add("h=" + path.getSrc()).add("hp=" + path.getDst()) .add("hb=" + changeSet.getId()).add("hpb=" + changeSet.getParentCommit()).toString(); return new URL(url, url.getPath() + spec); }
/** * Creates a link to the file. * http://[CGit URL]/tree/[path]?id=[commit] * * @param path affected file path * @return diff link * @throws IOException */ @Override public URL getFileLink(Path path) throws IOException { GitChangeSet changeSet = path.getChangeSet(); if (path.getEditType() == EditType.DELETE) { return new URL(url, url.getPath() + "tree/" + path.getPath() + param().add("id=" + changeSet.getParentCommit()).toString()); } else { return new URL(url, url.getPath() + "tree/" + path.getPath() + param().add("id=" + changeSet.getId()).toString()); } }
/** * Creates a link to the file. * https://[ODCS URL]/blob/pom.xml?revision=a9182a07750c9a0dfd89a8461adf72ef5ef0885b * * @param path * @return file link * @throws IOException */ @Override public URL getFileLink(Path path) throws IOException { if (path.getEditType().equals(EditType.DELETE)) { return getDiffLink(path); } else { String changeSetURLString = String.format("%s/blob/%s?revision=%s", urlAsStringWithoutSlash(), path.getPath(), path.getChangeSet().getId()); return new URL(changeSetURLString); } }
/** * Creates a link to the file. * http://[GitHib URL]/blob/573670a3bb1f3b939e87f1dee3e99b6bfe281fcb/src/main/java/hudson/plugins/git/browser/GithubWeb.java * Github seems to have no URL for deleted files, so just return * a difflink instead. * * @param path file * @return file link * @throws IOException */ @Override public URL getFileLink(Path path) throws IOException { if (path.getEditType().equals(EditType.DELETE)) { return getDiffLinkRegardlessOfEditType(path); } else { final String spec = "blob/" + path.getChangeSet().getId() + "/" + path.getPath(); return new URL(url, url.getPath() + spec); } }
/** * {@inheritDoc} */ @Override public URL getFileLink(Path path) throws IOException { if (path.getEditType().equals(EditType.DELETE)) { return diffLink(path); } else { return new URL( UriTemplate.buildFromTemplate(getRepoUrl()) .literal("/src") .path(UriTemplateBuilder.var("changeSet")) .path(UriTemplateBuilder.var("path", true)) .build() .set("changeSet", path.getChangeSet().getId()) .set("path", StringUtils.split(path.getPath(), '/')) .expand() ); } }