You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2022/06/20 13:26:17 UTC

[isis] branch ISIS-3078 created (now b9498061b0)

This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a change to branch ISIS-3078
in repository https://gitbox.apache.org/repos/asf/isis.git


      at b9498061b0 ISIS-3078: fixes unit tests that would break after rename

This branch includes the following new commits:

     new ba13aec3b1 ISIS-3078: adds script to perform bulk rename
     new b9498061b0 ISIS-3078: fixes unit tests that would break after rename

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[isis] 02/02: ISIS-3078: fixes unit tests that would break after rename

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch ISIS-3078
in repository https://gitbox.apache.org/repos/asf/isis.git

commit b9498061b001d344bac2303e6404f7c7ba5b5de6
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Mon Jun 20 14:26:08 2022 +0100

    ISIS-3078: fixes unit tests that would break after rename
---
 .../java/org/apache/isis/commons/internal/strings/FormatTest.java     | 2 +-
 .../apache/isis/testdomain/domainmodel/MetaModelRegressionTest.java   | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/commons/src/test/java/org/apache/isis/commons/internal/strings/FormatTest.java b/commons/src/test/java/org/apache/isis/commons/internal/strings/FormatTest.java
index 73e3056310..af67b8599f 100644
--- a/commons/src/test/java/org/apache/isis/commons/internal/strings/FormatTest.java
+++ b/commons/src/test/java/org/apache/isis/commons/internal/strings/FormatTest.java
@@ -77,7 +77,7 @@ public class FormatTest {
 
     @Test
     public void real_world() {
-        Assertions.assertEquals("isisx.persistence.\njdo-dataxnucleus.\nclass-metadata-\nloaded-listener", format("isisx.persistence.jdo-dataxnucleus.class-metadata-loaded-listener", 20));
+        Assertions.assertEquals("isxs.persistence.\njdo-dataxnucleus.\nclass-metadata-\nloaded-listener", format("isxs.persistence.jdo-dataxnucleus.class-metadata-loaded-listener", 20));
     }
 
 
diff --git a/regressiontests/stable-domainmodel/src/test/java/org/apache/isis/testdomain/domainmodel/MetaModelRegressionTest.java b/regressiontests/stable-domainmodel/src/test/java/org/apache/isis/testdomain/domainmodel/MetaModelRegressionTest.java
index e5e0912508..8218e15d61 100644
--- a/regressiontests/stable-domainmodel/src/test/java/org/apache/isis/testdomain/domainmodel/MetaModelRegressionTest.java
+++ b/regressiontests/stable-domainmodel/src/test/java/org/apache/isis/testdomain/domainmodel/MetaModelRegressionTest.java
@@ -26,6 +26,7 @@ import java.util.List;
 
 import javax.inject.Inject;
 
+import org.assertj.core.api.Assumptions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.springframework.boot.test.context.SpringBootTest;
@@ -87,6 +88,9 @@ class MetaModelRegressionTest {
     @Test
     @SneakyThrows
     void metaModelDiff_compareWithLastKnownGood() {
+
+        Assumptions.assumeThat(getClass().getName()).contains("isis");  // disable if rename, as the .zip file needs to be updated.
+
         val downloadMetaModelDiff =
                 factoryService.mixin(MetaModelServiceMenu.downloadMetaModelDiff.class, metaModelServiceMenu);
         val metamodelExport =


[isis] 01/02: ISIS-3078: adds script to perform bulk rename

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch ISIS-3078
in repository https://gitbox.apache.org/repos/asf/isis.git

commit ba13aec3b10fda56f841ad9daee80a455a444c02
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Mon Jun 20 14:21:35 2022 +0100

    ISIS-3078: adds script to perform bulk rename
---
 scripts/rename/.gitignore      |   1 +
 scripts/rename/src/Main.groovy | 176 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 177 insertions(+)

diff --git a/scripts/rename/.gitignore b/scripts/rename/.gitignore
new file mode 100644
index 0000000000..c3af857904
--- /dev/null
+++ b/scripts/rename/.gitignore
@@ -0,0 +1 @@
+lib/
diff --git a/scripts/rename/src/Main.groovy b/scripts/rename/src/Main.groovy
new file mode 100644
index 0000000000..e2a67c7ec5
--- /dev/null
+++ b/scripts/rename/src/Main.groovy
@@ -0,0 +1,176 @@
+/**
+ * This doesn't rewrite the contents of the following (binary) extensions:
+ *
+ * .jar
+ * .zip
+ *
+ * .pptx
+ * .docx
+ * .xlsx
+ *
+ * .odt
+ * .rtf
+ * .pdf
+ *
+ */
+class RenameAndRewrite {
+
+  // root of the repo
+  static final ROOT_DIR = "../../.."
+  //static final ROOT_DIR = "../../.." + "/persistence/jdo/metamodel/src/main/resources/META-INF/services"
+
+  static final FROM_LOWERCASE = "isis"
+  static final TO_LOWERCASE = "causeway"
+
+  static final FROM_TITLECASE = FROM_LOWERCASE.capitalize()
+  static final TO_TITLECASE = TO_LOWERCASE.capitalize()
+
+  static final FROM_UPPERCASE = FROM_LOWERCASE.toUpperCase()
+  static final TO_UPPERCASE = TO_LOWERCASE.toUpperCase()
+
+
+  // to obtain all the suffixes:
+  // find . -type f | sed -rn 's|.*/[^/]+\.([^/.]+)$|\1|p' | sort -u
+  static final EXTENSIONS = [
+          "NOTICE",
+          "STATUS",
+          "ConstraintValidator",
+          "CausewayBeanTypeClassifier",
+          "MF",
+          "TXT",
+          "UriBuilderPlugin",
+          "adoc",
+          "bat",
+          "cfg",
+          "css",
+          "dcl",
+          "dtd",
+          "factories",
+          "feature",
+          "fxml",
+          "gql",
+          "graphqls",
+          "hbs",
+          "html",
+          "importorder",
+          "info",
+          "ini",
+          "java",
+          "jdo",
+          "js",
+          "json",
+          "kt",
+          "kts",
+          "ldif",
+          "list",
+          "md",
+          "po",
+          "pot",
+          "properties",
+          "puml",
+          "rdf",
+          "sh",
+          "soc",
+          "svg",
+          "template",
+          "thtml",
+          "ts",
+          "txt",
+          "xml",
+          "xsd",
+          "yaml",
+          "yml"
+  ]
+
+  def renameAllFiles() {
+
+    def currentDir = new File(ROOT_DIR)
+
+    currentDir.eachFileRecurse { File file ->
+      if (file.isDirectory()) {
+        return
+      }
+      renameIfRequired(file)
+    }
+  }
+
+  def renameIfRequired(File file) {
+    def filePathRename = file.path
+            .replaceAll(FROM_TITLECASE, TO_TITLECASE)
+            .replaceAll(FROM_UPPERCASE, TO_UPPERCASE)
+            .replaceAll("\\\\" + FROM_LOWERCASE, "\\\\" + TO_LOWERCASE)
+            .replaceAll("/" + FROM_LOWERCASE, "/" + TO_LOWERCASE)
+            .replaceAll("-" + FROM_LOWERCASE, "-" + TO_LOWERCASE)
+            .replaceAll("_" + FROM_LOWERCASE, "_" + TO_LOWERCASE)
+            .replaceAll("[.]" + FROM_LOWERCASE, "." + TO_LOWERCASE)
+
+    if (!filePathRename.equals(file.path)) {
+
+      println "${file.path} -> ${filePathRename}"
+
+      def fileRename = new File(filePathRename)
+      def parentFile = fileRename.parentFile
+      parentFile.mkdirs()
+
+      file.renameTo(fileRename)
+    }
+  }
+
+  def rewriteAllFileContents() {
+
+    def currentDir = new File(ROOT_DIR)
+
+    currentDir.eachFileRecurse { file ->
+      // println "${file.path}"
+      if (!file.exists()) {
+        return
+      }
+      if (file.isDirectory()) {
+        return
+      }
+      if (file.path.contains(".git\\" )) {
+        return
+      }
+
+      if(fileNameEndsWithSupportedExtension(file)) {
+        rewriteIfRequired(file)
+      }
+    }
+  }
+
+  private void rewriteIfRequired(File file) {
+    def fileText = file.text
+    def updatedFileText = fileText
+            .replaceAll(FROM_LOWERCASE, TO_LOWERCASE)
+            .replaceAll(FROM_UPPERCASE, TO_UPPERCASE)
+            .replaceAll(FROM_TITLECASE, TO_TITLECASE)
+
+    if (!fileText.equals(updatedFileText)) {
+
+      println "rewriting ${file.path}"
+
+      file.write(updatedFileText)
+    }
+  }
+
+
+  private boolean fileNameEndsWithSupportedExtension(File file) {
+    for (ext in EXTENSIONS) {
+      if (file.name.endsWith(ext)) {
+        return true
+      }
+    }
+    return false
+  }
+
+}
+
+
+
+static void main(String[] args) {
+  def rr = new RenameAndRewrite()
+
+  rr.renameAllFiles()
+  rr.rewriteAllFileContents()
+}
+