branch develop updated (f58047b -> f54b36c)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository scmwebeditor. See http://git.nuiton.org/scmwebeditor.git from f58047b The page is reloaded after uploading or removing a file and after creating a branch to avoid errors new f54b36c Change the branch to the given one when accessing to a file by an URL The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit f54b36ce43984ff4a5000cd3d486cb4f33422b05 Author: Hugo PIGEON <hpigeon@codelutin.com> Date: Thu May 21 15:01:58 2015 +0200 Change the branch to the given one when accessing to a file by an URL Summary of changes: .../org/nuiton/scmwebeditor/git/GitConnection.java | 1 + .../org/nuiton/scmwebeditor/git/GitProvider.java | 40 ++++++++++++++++++++-- .../org/nuiton/scmwebeditor/api/ScmProvider.java | 12 +++++++ .../org/nuiton/scmwebeditor/svn/SvnProvider.java | 6 ++++ .../scmwebeditor/uiweb/actions/EditAction.java | 23 +++++++++++++ 5 files changed, 80 insertions(+), 2 deletions(-) -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository scmwebeditor. See http://git.nuiton.org/scmwebeditor.git commit f54b36ce43984ff4a5000cd3d486cb4f33422b05 Author: Hugo PIGEON <hpigeon@codelutin.com> Date: Thu May 21 15:01:58 2015 +0200 Change the branch to the given one when accessing to a file by an URL --- .../org/nuiton/scmwebeditor/git/GitConnection.java | 1 + .../org/nuiton/scmwebeditor/git/GitProvider.java | 40 ++++++++++++++++++++-- .../org/nuiton/scmwebeditor/api/ScmProvider.java | 12 +++++++ .../org/nuiton/scmwebeditor/svn/SvnProvider.java | 6 ++++ .../scmwebeditor/uiweb/actions/EditAction.java | 23 +++++++++++++ 5 files changed, 80 insertions(+), 2 deletions(-) diff --git a/swe-git/src/main/java/org/nuiton/scmwebeditor/git/GitConnection.java b/swe-git/src/main/java/org/nuiton/scmwebeditor/git/GitConnection.java index 7867bd6..e152c4b 100644 --- a/swe-git/src/main/java/org/nuiton/scmwebeditor/git/GitConnection.java +++ b/swe-git/src/main/java/org/nuiton/scmwebeditor/git/GitConnection.java @@ -827,6 +827,7 @@ public class GitConnection implements ScmConnection { if (log.isErrorEnabled()) { log.error("Can not checkout branch " + branchName, e1); } + throw new IOException("Can not checkout branch " + branchName, e1); } } } diff --git a/swe-git/src/main/java/org/nuiton/scmwebeditor/git/GitProvider.java b/swe-git/src/main/java/org/nuiton/scmwebeditor/git/GitProvider.java index 97551f5..95ea4f0 100644 --- a/swe-git/src/main/java/org/nuiton/scmwebeditor/git/GitProvider.java +++ b/swe-git/src/main/java/org/nuiton/scmwebeditor/git/GitProvider.java @@ -159,8 +159,6 @@ public class GitProvider implements ScmProvider { push.call(); } catch (GitAPIException e) { - error = AbstractResultDto.ERROR; - String logMessage = "Can not push"; if (e instanceof NoHeadException) { @@ -210,6 +208,44 @@ public class GitProvider implements ScmProvider { } @Override + public String changeBranch(String branchName, String pathToLocalRepos, String username, String password) + throws OperationNotSupportedException { + + String error = null; + GitConnection conn = (GitConnection) getConnection(address, pathToLocalRepos); + + try { + conn.updateRepository(username, password); + + try { + conn.changeBranch(branchName); + } catch (IOException e) { + if (log.isErrorEnabled()) { + log.error("Can not change branch to " + branchName, e); + } + error = AbstractResultDto.ERROR; + } + } catch (RepositoryNotFoundException e) { + if (log.isErrorEnabled()) { + log.error("Can not reach repository " + address, e); + } + error = AbstractResultDto.ERROR; + } catch (IOException e) { + if (log.isErrorEnabled()) { + log.error("Can not reach repository " + address, e); + } + error = AbstractResultDto.ERROR; + } catch (AuthenticationException e) { + if (log.isErrorEnabled()) { + log.error("Authentication problem for repository at address " + address, e); + } + error = AbstractResultDto.AUTH_ERROR; + } + + return error; + } + + @Override public boolean supportsPush() { return true; } diff --git a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmProvider.java b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmProvider.java index bf053d6..46bbc63 100644 --- a/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmProvider.java +++ b/swe-scm-api/src/main/java/org/nuiton/scmwebeditor/api/ScmProvider.java @@ -59,6 +59,18 @@ public interface ScmProvider { AuthenticationException, RepositoryNotFoundException; /** + * Changes the working branch for the local repository + * @param branchName the new working branch + * @param pathToLocalRepos the path to the directory where the local repositories are stored + * @param username the username to use to connect to the repository + * @param password the password to use to connect to the repository + * @return an error code or null if there was no error during the process + * @throws OperationNotSupportedException if the SCM doesn't support branches + */ + String changeBranch(String branchName, String pathToLocalRepos, String username, String password) + throws OperationNotSupportedException; + + /** * Tells whether the SCM allows to choose when the commits are pushed to the server * @return true if the SCM supports a command to push the commits to the server */ diff --git a/swe-svn/src/main/java/org/nuiton/scmwebeditor/svn/SvnProvider.java b/swe-svn/src/main/java/org/nuiton/scmwebeditor/svn/SvnProvider.java index f5b6c10..6b3fdf4 100644 --- a/swe-svn/src/main/java/org/nuiton/scmwebeditor/svn/SvnProvider.java +++ b/swe-svn/src/main/java/org/nuiton/scmwebeditor/svn/SvnProvider.java @@ -70,6 +70,12 @@ public class SvnProvider implements ScmProvider { } @Override + public String changeBranch(String branchName, String pathToLocalRepos, String username, String password) + throws OperationNotSupportedException { + throw new OperationNotSupportedException("The 'change branch' operation is not available for SVN repositories"); + } + + @Override public boolean supportsPush() { return false; } diff --git a/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/EditAction.java b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/EditAction.java index c198061..dd4460a 100644 --- a/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/EditAction.java +++ b/swe-ui-web/src/main/java/org/nuiton/scmwebeditor/uiweb/actions/EditAction.java @@ -26,9 +26,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.shiro.codec.Base64; import org.apache.shiro.crypto.BlowfishCipherService; +import org.nuiton.scmwebeditor.api.OperationNotSupportedException; import org.nuiton.scmwebeditor.api.ScmConnection; import org.nuiton.scmwebeditor.api.ScmProvider; import org.nuiton.scmwebeditor.api.ScmWebEditorConfig; +import org.nuiton.scmwebeditor.api.dto.result.AbstractResultDto; import javax.naming.AuthenticationException; import javax.servlet.http.Cookie; @@ -141,6 +143,7 @@ public class EditAction extends ScmWebEditorMainAction { } + // authentication String[] usernamePw = getUsernamePwFromSession(repositoryUUID, username, pw); username = usernamePw[0]; pw = usernamePw[1]; @@ -155,6 +158,26 @@ public class EditAction extends ScmWebEditorMainAction { password = "anonymous"; } + String changeBranchError = null; + + if (scmSupportsBranches) { + try { + changeBranchError = provider.changeBranch(selectedBranch, pathToLocalRepos, username, pw); + } catch (OperationNotSupportedException e) { + if (log.isErrorEnabled()) { + log.error("Can not change branch with SCM '" + scmType + "'"); + } + } + } + + if (changeBranchError != null) { + if (changeBranchError.equals(AbstractResultDto.AUTH_ERROR)) { + return LOGIN; + } else { + return ERROR_PATH; + } + } + /* * Getting the file and its revision -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm