This is an automated email from the git hooks/post-receive script. New commit to branch feature/GIT in repository scmwebeditor. See http://git.nuiton.org/scmwebeditor.git commit 08c4bd2582116621a278573c642ece2e8346bf59 Author: Hugo PIGEON <hpigeon@codelutin.com> Date: Wed May 6 14:05:29 2015 +0200 Added the display of the branch name in the editor when using a SCM which supports branches --- .../org/nuiton/scmwebeditor/GitConnection.java | 24 ++++++---------------- .../nuiton/scmwebeditor/actions/BrowseAction.java | 6 ------ .../nuiton/scmwebeditor/actions/EditAction.java | 23 +++++++++++++++++++++ .../resources/i18n/scmwebeditor_en_GB.properties | 3 ++- .../resources/i18n/scmwebeditor_fr_FR.properties | 1 + src/main/webapp/WEB-INF/content/browse.jsp | 19 +++++++++++++---- .../webapp/WEB-INF/content/modificationViewer.jsp | 15 +++++++++++--- 7 files changed, 59 insertions(+), 32 deletions(-) diff --git a/src/main/java/org/nuiton/scmwebeditor/GitConnection.java b/src/main/java/org/nuiton/scmwebeditor/GitConnection.java index 34d5ca7..5d88abc 100644 --- a/src/main/java/org/nuiton/scmwebeditor/GitConnection.java +++ b/src/main/java/org/nuiton/scmwebeditor/GitConnection.java @@ -194,8 +194,10 @@ public class GitConnection implements ScmConnection { // if the id parameter is not given, we look for the root if (id.equals("")) { + resultDto.setError(BrowseResultDto.ROOT); return resultDto; + } else if (id.equals("0")) { url = address; } else { @@ -637,7 +639,6 @@ public class GitConnection implements ScmConnection { if (log.isErrorEnabled()) { log.error("Error while cloning the repository", e); } - } catch (IOException e) { if (log.isErrorEnabled()) { @@ -669,7 +670,6 @@ public class GitConnection implements ScmConnection { if (log.isErrorEnabled()) { log.error("Error while cloning the repository", e); } - } catch (IOException e) { if (log.isErrorEnabled()) { @@ -677,25 +677,13 @@ public class GitConnection implements ScmConnection { } } - Git git = null; + String headRevision = null; try { - git = Git.open(localDirectory); + ObjectId commitId = gitRepo.resolve(Constants.HEAD); + headRevision = commitId.getName(); } catch (IOException e) { - if (log.isErrorEnabled()) { - log.error("Can not open local directory " + localDirectory.getAbsolutePath(), e); - } - } - - DescribeCommand describeCommand = git.describe(); - - String headRevision = null; - try { - headRevision = describeCommand.call(); - } catch (GitAPIException e) { - if (log.isErrorEnabled()) { - log.error("Can not use the Git describe command", e); - } + e.printStackTrace(); } return headRevision; diff --git a/src/main/java/org/nuiton/scmwebeditor/actions/BrowseAction.java b/src/main/java/org/nuiton/scmwebeditor/actions/BrowseAction.java index 8b7b9f1..fe377c8 100644 --- a/src/main/java/org/nuiton/scmwebeditor/actions/BrowseAction.java +++ b/src/main/java/org/nuiton/scmwebeditor/actions/BrowseAction.java @@ -41,7 +41,6 @@ import javax.servlet.http.HttpSession; import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.Set; public class BrowseAction extends AbstractScmWebEditorAction implements ServletResponseAware { @@ -167,11 +166,6 @@ public class BrowseAction extends AbstractScmWebEditorAction implements ServletR scmSupportsBranches = provider.supportsBranches(); - if (provider == null) { - error = true; - return ROOT; - } - ScmConnection scmConn = provider.getConnection(address, sessionId); // putting all the parameters into a DTO diff --git a/src/main/java/org/nuiton/scmwebeditor/actions/EditAction.java b/src/main/java/org/nuiton/scmwebeditor/actions/EditAction.java index 9cc7ad7..2685cad 100644 --- a/src/main/java/org/nuiton/scmwebeditor/actions/EditAction.java +++ b/src/main/java/org/nuiton/scmwebeditor/actions/EditAction.java @@ -19,13 +19,36 @@ public class EditAction extends ScmWebEditorMainAction { private static final Log log = LogFactory.getLog(EditAction.class); + protected String selectedBranch; + + protected boolean scmSupportsBranches; + + public String getSelectedBranch() { + return selectedBranch; + } + + public void setSelectedBranch(String selectedBranch) { + this.selectedBranch = selectedBranch; + } + + public boolean isScmSupportsBranches() { + return scmSupportsBranches; + } + + public void setScmSupportsBranches(boolean scmSupportsBranches) { + this.scmSupportsBranches = scmSupportsBranches; + } + public String edit() { + HttpSession session = request.getSession(); String sessionId = session.getId(); ScmProvider provider = getProvider(scmType); ScmConnection scmConn = provider.getConnection(address, sessionId); + scmSupportsBranches = provider.supportsBranches(); + format = scmConn.getFileName().substring(scmConn.getFileName().lastIndexOf(".") + 1); String originalText = ""; diff --git a/src/main/resources/i18n/scmwebeditor_en_GB.properties b/src/main/resources/i18n/scmwebeditor_en_GB.properties index 4d897dd..dd131d5 100644 --- a/src/main/resources/i18n/scmwebeditor_en_GB.properties +++ b/src/main/resources/i18n/scmwebeditor_en_GB.properties @@ -17,7 +17,7 @@ scm.exitTitle=Exit ScmWebEditor without saving. scm.fileModify=File modify while editing. scm.forceSave=Force save scm.formTransferred=You should be transferred automatically to the form page. If not please -scm.info.ProblemWithRst=For any Problem with RestructuredText visit +scm.info.ProblemWithRst=For any problem with RestructuredText visit scm.info.rstWebsite=RST documentation website scm.language=Language scm.lastChangeSave=Last change save @@ -25,6 +25,7 @@ scm.logAs=You are log as \: scm.loginButton=Login scm.logoutWait=Logout... scm.modificationViewer.betterUseJavascript=For a better use of SCMWebEditor please activate JavaScript. +scm.modificationViewer.branch=Working on branch\: scm.modificationViewer.noJavascript=Javascript is not activated. You can't only use Save and Quit or upload button. scm.mustBeLog=You must be login to see this repository. scm.no=No diff --git a/src/main/resources/i18n/scmwebeditor_fr_FR.properties b/src/main/resources/i18n/scmwebeditor_fr_FR.properties index 1d144f0..3ca9f6d 100644 --- a/src/main/resources/i18n/scmwebeditor_fr_FR.properties +++ b/src/main/resources/i18n/scmwebeditor_fr_FR.properties @@ -25,6 +25,7 @@ scm.logAs=Connecté en tant que \: scm.loginButton=Connexion scm.logoutWait=Déconnexion... scm.modificationViewer.betterUseJavascript=Activer Javascript pour accéder à toutes les fonctionnalités. +scm.modificationViewer.branch=Vous travaillez sur la branche \: scm.modificationViewer.noJavascript=Javascript est désactivé. Vous pouvez seulement utiliser les boutons sauvegarder et quitter, quitter ou ajouter un fichier. scm.mustBeLog=Vous devez vous identifier pour parcourir ce dépôt. scm.no=Non diff --git a/src/main/webapp/WEB-INF/content/browse.jsp b/src/main/webapp/WEB-INF/content/browse.jsp index e5a1be5..7449f2d 100644 --- a/src/main/webapp/WEB-INF/content/browse.jsp +++ b/src/main/webapp/WEB-INF/content/browse.jsp @@ -38,7 +38,10 @@ if (classAttr == "jstree-leaf") { var scmType = $("#scmType").val(); - document.location.href = ("edit.action?address=" + item.attr("id") + "&scmType=" + scmType); + var selectedBranch = $("#selectedBranchDisplay").text().trim(); + + document.location.href = ("edit.action?address=" + item.attr("id") + "&scmType=" + scmType + + "&selectedBranch=" + selectedBranch); } } @@ -67,17 +70,25 @@ <script src="js/pictureUpload.js" type="text/javascript"></script> <s:if test="scmSupportsBranches && !error"> + <s:text name="scm.outConnection.headBranch"/> + <s:if test="selectedBranch != null"> <s:if test="!selectedBranch.equals('')"> - <s:label name="selectedBranch"></s:label> + + <s:label id="selectedBranchDisplay" name="selectedBranch"></s:label> + </s:if> <s:else> - <s:label name="headBranchName"></s:label> + + <s:label id="selectedBranchDisplay" name="headBranchName"></s:label> + </s:else> </s:if> <s:else> - <s:label name="headBranchName"></s:label> + + <s:label id="selectedBranchDisplay" name="headBranchName"></s:label> + </s:else> </s:if> diff --git a/src/main/webapp/WEB-INF/content/modificationViewer.jsp b/src/main/webapp/WEB-INF/content/modificationViewer.jsp index c174c96..fb6c578 100644 --- a/src/main/webapp/WEB-INF/content/modificationViewer.jsp +++ b/src/main/webapp/WEB-INF/content/modificationViewer.jsp @@ -91,8 +91,10 @@ <img src="img/flag-i18n-uk.png"/> </s:if> <s:else> - <s:a action="checkout.action" namespace="/"> + <s:a action="edit.action" namespace="/"> <s:param name="address"><s:property value="address"/></s:param> + <s:param name="scmType"><s:property value="scmType"/></s:param> + <s:param name="selectedBranch"><s:property value="selectedBranch"/></s:param> <s:param name="request_locale">en_GB</s:param> <img src="img/flag-i18n-uk.png"/> </s:a> @@ -104,8 +106,10 @@ <img src="img/flag-i18n-fr.png"/> </s:if> <s:else> - <s:a action="checkout.action" namespace="/"> + <s:a action="edit.action" namespace="/"> <s:param name="address"><s:property value="address"/></s:param> + <s:param name="scmType"><s:property value="scmType"/></s:param> + <s:param name="selectedBranch"><s:property value="selectedBranch"/></s:param> <s:param name="request_locale">fr_FR</s:param> <img src="img/flag-i18n-fr.png"/> </s:a> @@ -331,6 +335,11 @@ value="address"/></s:a> <s:text name="scm.atRevision"/> <span id="numrevisionDiv"><s:property value="numRevision"/></span> + + <s:if test="scmSupportsBranches"> + <br/> + <s:text name="scm.modificationViewer.branch"/> <s:property value="selectedBranch"></s:property> + </s:if> </p> <s:if test="format == 'rst'"> @@ -468,6 +477,6 @@ <div id="targetContentUpload"></div> </div> -<p align="right">©2004-2014 CodeLutin</p> +<p align="right">©2004-2015 CodeLutin</p> </body> </html> -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.