Skip to content

Commit

Permalink
Remove module IDs during remove
Browse files Browse the repository at this point in the history
Fixes #121
  • Loading branch information
lptr committed Nov 14, 2014
1 parent 4f6f5fe commit 3bdcad9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public ConfigurationData<M> loadConfiguration(Configuration fileConfiguration) {
}

public void saveConfiguration(Configuration configuration, Collection<M> modules) {
for (String moduleKey : Iterators.toArray(configuration.getKeys(MODULES_KEY), String.class)) {
configuration.clearProperty(moduleKey);
}
int id = 0;
for (M module : modules) {
String moduleId = MODULES_KEY + "." + id;
Expand Down
34 changes: 31 additions & 3 deletions pride-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ project(':git-module').projectDir = file('git-module')
assert rawContents("$dir/.pride/version", "#") == """
0
"""
assert rawContents("$dir/.pride/config", "#") == """
assert asProps(file("$dir/.pride/config")) == asProps("""
gradle.version = 2.0
modules.0.name = file-module
modules.0.vcs = file
modules.1.name = git-module
modules.1.vcs = git
"""
""")
assert rawContents("$dir/.pride/projects", "#") == """
com.example.test.file:file-module::file-module
com.example.test.git:git-module::git-module
Expand All @@ -56,7 +56,7 @@ com.example.test.git:git-module::git-module
def exportFile = file("$temporaryDir/export.pride")
pride(dir, "export", "--output", exportFile, "-O")

assert rawContents(exportFile, "#") == """
assert asProps(exportFile) == asProps("""
gradle.version = 2.0
modules.0.name = file-module
modules.0.vcs = file
Expand All @@ -66,6 +66,20 @@ modules.0.remote = ${dir}/file-module
modules.0.revision = none
modules.1.remote = [email protected]:prezi/test
modules.1.revision = master
""")

pride(dir, "remove", "file-module")
assert rawContents("$dir/settings.gradle", "//") == """
include 'git-module'
project(':git-module').projectDir = file('git-module')
"""
assert asProps(file("$dir/.pride/config")) == asProps("""
gradle.version = 2.0
modules.0.name = git-module
modules.0.vcs = git
""")
assert rawContents("$dir/.pride/projects", "#") == """
com.example.test.git:git-module::git-module
"""
}
}
Expand Down Expand Up @@ -152,3 +166,17 @@ def copyTest(Task task, String name, Map filters = [:]) {
def rawContents(Object f, String comment) {
"\n" + file(f).text.split("\n").findAll { !it.isEmpty() && !it.startsWith(comment) }.join("\n") + "\n"
}

def asProps(String contents) {
def props = new Properties()
props.load(new StringReader(contents))
return props
}

def asProps(File f) {
def props = new Properties()
f.withInputStream {
props.load(it)
}
return props
}

0 comments on commit 3bdcad9

Please sign in to comment.