This is an automated email from the ASF dual-hosted git repository.
nmalin pushed a commit to branch release24.09
in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git
The following commit(s) were added to refs/heads/release24.09 by this push:
new ae0c279b9 Improved: svn call on scrum plugin (OFBIZ-13276)
ae0c279b9 is described below
commit ae0c279b9c7bb91a36d038f2dab5941b09b1de09
Author: Nicolas Malin <[email protected]>
AuthorDate: Sat Jul 26 07:41:33 2025 +0200
Improved: svn call on scrum plugin (OFBIZ-13276)
On scrum plugin when we call the svn command to retrieve a revision diff we
call directly the os system by a concat string.
We improve that to pass the command with a string table
---
scrum/minilang/test/TaskTests.xml | 22 +++++++++++++++++++++-
.../java/org/apache/ofbiz/scrum/ScrumServices.java | 20 +++++++++++---------
scrum/testdef/scrumTests.xml | 4 ++--
3 files changed, 34 insertions(+), 12 deletions(-)
diff --git a/scrum/minilang/test/TaskTests.xml
b/scrum/minilang/test/TaskTests.xml
index e07233171..ee011f04e 100644
--- a/scrum/minilang/test/TaskTests.xml
+++ b/scrum/minilang/test/TaskTests.xml
@@ -20,7 +20,7 @@ under the License.
<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://ofbiz.apache.org/Simple-Method"
xsi:schemaLocation="http://ofbiz.apache.org/Simple-Method
http://ofbiz.apache.org/dtds/simple-methods.xsd">
-
+ <!--
<simple-method method-name="testViewScrumRevision"
short-description="Test View Scrum Revision" login-required="false">
<entity-one entity-name="UserLogin" value-field="userLogin">
<field-map field-name="userLoginId" value="system"/>
@@ -36,10 +36,29 @@ under the License.
<and>
<not><if-empty field="result.repository"/></not>
<not><if-empty field="result.revision"/></not>
+ <not><if-empty field="result.logMessage"/></not>
</and>
</assert>
<check-errors/>
</simple-method>
+ -->
+ <simple-method method-name="testViewScrumRevisionBadCall"
short-description="Test View Scrum Revision resist to a bad call"
login-required="false">
+ <entity-one entity-name="UserLogin" value-field="userLogin">
+ <field-map field-name="userLoginId" value="system"/>
+ </entity-one>
+ <set-current-user-login value-field="userLogin"/>
+ <set field="serviceCtx.userLogin" from-field="userLogin"/>
+ <set field="serviceCtx.repository"
value="--diff+--diff-cmd=/bin/ls"/>
+ <set field="serviceCtx.revision" value="7"/>
+ <call-service service-name="viewScrumRevision"
in-map-name="serviceCtx">
+ <results-to-map map-name="result"/>
+ </call-service>
+ <assert>
+ <if-empty field="result.logMessage"/>
+ </assert>
+ <check-errors/>
+ </simple-method>
+ <!--
<simple-method method-name="testRetrieveMissingScrumRevision"
short-description="Test Retrieve Missing Scrum Revision" login-required="false">
<entity-one entity-name="UserLogin" value-field="userLogin">
<field-map field-name="userLoginId" value="system"/>
@@ -75,4 +94,5 @@ under the License.
</assert>
<check-errors/>
</simple-method>
+ -->
</simple-methods>
diff --git a/scrum/src/main/java/org/apache/ofbiz/scrum/ScrumServices.java
b/scrum/src/main/java/org/apache/ofbiz/scrum/ScrumServices.java
index a8f75972c..098cba7d2 100644
--- a/scrum/src/main/java/org/apache/ofbiz/scrum/ScrumServices.java
+++ b/scrum/src/main/java/org/apache/ofbiz/scrum/ScrumServices.java
@@ -28,8 +28,8 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
-
import org.apache.ofbiz.base.util.Debug;
+import org.apache.ofbiz.base.util.StringUtil;
import org.apache.ofbiz.base.util.UtilMisc;
import org.apache.ofbiz.base.util.UtilProperties;
import org.apache.ofbiz.base.util.UtilValidate;
@@ -138,17 +138,18 @@ public class ScrumServices {
StringBuilder logMessage = new StringBuilder();
StringBuilder diffMessage = new StringBuilder();
try {
- if (UtilValidate.isNotEmpty(repository) &&
UtilValidate.isNotEmpty(revision)) {
+ if (UtilValidate.isNotEmpty(repository) &&
UtilValidate.isNotEmpty(revision)
+ && UtilValidate.isValidUrl(repository) &&
UtilValidate.isInteger(revision)) {
String logline = null;
- String logCommand = "svn log -r" + revision + " " + repository;
- Process logProcess = Runtime.getRuntime().exec(logCommand);
+ Process logProcess = Runtime.getRuntime().exec("svn",
+ new String[]{"log", "-r", revision, repository});
BufferedReader logIn = new BufferedReader(new
InputStreamReader(logProcess.getInputStream()));
while ((logline = logIn.readLine()) != null) {
logMessage.append(logline).append("\n");
}
String diffline = null;
- String diffCommand = "svn diff -r" +
Integer.toString((Integer.parseInt(revision.trim()) - 1)) + ":" + revision + "
" + repository;
- Process diffProcess = Runtime.getRuntime().exec(diffCommand);
+ Process diffProcess = Runtime.getRuntime().exec("svn",
+ new String[]{"diff", "-r",
StringUtil.addToNumberString(revision.trim(), -1) + ":" + revision,
repository});
BufferedReader diffIn = new BufferedReader(new
InputStreamReader(diffProcess.getInputStream()));
while ((diffline = diffIn.readLine()) != null) {
diffMessage.append(diffline).append("\n");
@@ -181,13 +182,14 @@ public class ScrumServices {
String repositoryRoot = (String) context.get("repositoryRoot");
Map<String, Object> result = ServiceUtil.returnSuccess();
try {
- if (UtilValidate.isNotEmpty(repositoryRoot) &&
UtilValidate.isNotEmpty(latestRevision)) {
+ if (UtilValidate.isNotEmpty(repositoryRoot) &&
UtilValidate.isNotEmpty(latestRevision)
+ && UtilValidate.isValidUrl(repositoryRoot) &&
UtilValidate.isInteger(latestRevision)) {
Integer revision = Integer.parseInt(latestRevision.trim());
for (int i = 1; i <= revision; i++) {
String logline = null;
List<String> logMessageList = new LinkedList<>();
- String logCommand = "svn log -r" + i + " " +
repositoryRoot;
- Process logProcess = Runtime.getRuntime().exec(logCommand);
+ Process logProcess = Runtime.getRuntime().exec("svn",
+ new String[]{"log", "-r", String.valueOf(i),
repositoryRoot});
BufferedReader logIn = new BufferedReader(new
InputStreamReader(logProcess.getInputStream()));
while ((logline = logIn.readLine()) != null) {
logMessageList.add(logline.toString().trim());
diff --git a/scrum/testdef/scrumTests.xml b/scrum/testdef/scrumTests.xml
index e20efc34f..cbb2e73a9 100644
--- a/scrum/testdef/scrumTests.xml
+++ b/scrum/testdef/scrumTests.xml
@@ -41,9 +41,9 @@ under the License.
<test-case case-name="product-tests">
<simple-method-test
location="component://scrum/minilang/test/ProductTest.xml"/>
</test-case>
- <!--<test-case case-name="task-test">
+ <test-case case-name="task-test">
<simple-method-test
location="component://scrum/minilang/test/TaskTests.xml"/>
- </test-case>-->
+ </test-case>
<test-case case-name="myWork-test">
<simple-method-test
location="component://scrum/minilang/test/MyWorkTests.xml"/>
</test-case>