From dea769a93c0c7e4a5f0cb3d3135d2dd31e0c32d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Spo=CC=88nemann?= Date: Wed, 8 Jun 2016 13:18:00 +0200 Subject: [PATCH] Passing path to shell scripts as argument, created README.md --- splitting/README.md | 15 +++++++++++++ splitting/build.gradle | 2 +- splitting/git-filter-branch.sh | 2 +- .../xtext/splitting/ValidateSplitting.java | 22 +++++++++---------- 4 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 splitting/README.md diff --git a/splitting/README.md b/splitting/README.md new file mode 100644 index 000000000..a83febc96 --- /dev/null +++ b/splitting/README.md @@ -0,0 +1,15 @@ +# Repository Splitting + +This project provides tools for splitting the Xtext repository as described [in the Wiki](https://github.com/eclipse/xtext/wiki/Restructuring). This is the proposed work flow: + + 1. `../gradlew findProjects` creates `build/splitting/all-projects.txt`, a list of all projects (paths with a `.project` file) that have ever been in the history, and `build/splitting/unmapped-paths.txt`, a list of paths that are not covered by any project. + 2. Create `splitting.txt` based on the results of the previous step. This file must consist of lines of the form `path >> target-repos`, where `path` can be any file or directory in the repository and `target-repos` is either `delete` or a list of repository ids where that path should be included. + 3. `../gradlew clean validateSplitting` checks whether `splitting.txt` covers all files found in the history. + 4. `../gradlew generateRemovals` creates `build/splitting/removals-*.txt` for each target repository. + +Now you have all necessary data to perform the actual splitting. In order to do this: + + 1. Create and checkout a new branch. + 2. Run `../gradlew *FilterBranch`, where `*` is the target repository id. + 3. Find something else to do (on my machine the previous command takes more than one hour). + 4. Push the resulting branch to the corresponding repository. diff --git a/splitting/build.gradle b/splitting/build.gradle index b26c63310..c380b2c77 100644 --- a/splitting/build.gradle +++ b/splitting/build.gradle @@ -61,6 +61,6 @@ repositories.each { targetRepo -> dependsOn(generateRemovals) inputs.file removalsFile workingDir '..' - commandLine 'splitting/git-filter-branch.sh', removalsFile.path + commandLine 'splitting/git-filter-branch.sh', removalsFile.path, file('.').canonicalPath } } diff --git a/splitting/git-filter-branch.sh b/splitting/git-filter-branch.sh index b81fd229e..e7bd12306 100755 --- a/splitting/git-filter-branch.sh +++ b/splitting/git-filter-branch.sh @@ -3,5 +3,5 @@ REMOVALS=`cat $1 | tr '\n' ' '` git filter-branch -f --prune-empty \ --index-filter "git rm -qrf --cached --ignore-unmatch $REMOVALS" \ - --parent-filter splitting/parent-filter.sh \ + --parent-filter $2/parent-filter.sh \ HEAD diff --git a/splitting/src/org/eclipse/xtext/splitting/ValidateSplitting.java b/splitting/src/org/eclipse/xtext/splitting/ValidateSplitting.java index 2bddacc9b..0d66adf76 100644 --- a/splitting/src/org/eclipse/xtext/splitting/ValidateSplitting.java +++ b/splitting/src/org/eclipse/xtext/splitting/ValidateSplitting.java @@ -39,17 +39,16 @@ public class ValidateSplitting { while ((line = reader.readLine()) != null) { if (!line.isEmpty()) { String[] parts = line.split(">>"); - if (parts.length != 2) { + if (parts.length != 2) fail("Invalid line: " + line); - } - String[] repos = parts[1].split(","); - if (repos.length == 0) { - fail("Invalid line: " + line); - } - for (String repo : repos) { - String trimmed = repo.trim(); - if (!(REPOSITORIES.contains(trimmed) || DELETE.equals(trimmed))) { - fail("Invalid repository: " + trimmed); + if (!DELETE.equals(parts[1].trim())) { + String[] repos = parts[1].split(","); + if (repos.length == 0) + fail("Invalid line: " + line); + for (String repo : repos) { + String trimmed = repo.trim(); + if (!REPOSITORIES.contains(trimmed)) + fail("Invalid repository: " + trimmed); } } String path = parts[0].trim(); @@ -74,9 +73,8 @@ public class ValidateSplitting { if (specifiedPaths.contains(file.substring(0, lastMatch))) foundSplitting = true; } - if (!foundSplitting) { + if (!foundSplitting) fail("File not covered by splitting: " + file); - } } } }