Skip to content

Commit 6122e0e

Browse files
authored
📣 Release 2.4.1
2 parents 37fe48d + 24dcd43 commit 6122e0e

File tree

12 files changed

+81
-24
lines changed

12 files changed

+81
-24
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>fr.yodamad.svn2git</groupId>
66
<artifactId>svn-2-git</artifactId>
7-
<version>2.4.0</version>
7+
<version>2.4.1</version>
88
<packaging>jar</packaging>
99
<name>Svn 2 GitLab</name>
1010

src/main/java/fr/yodamad/svn2git/domain/Migration.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ public class Migration implements Serializable {
154154
@JsonView(View.Public.class)
155155
private Boolean cleaning = true;
156156

157+
@Column(name = "uppercase")
158+
@JsonView(View.Public.class)
159+
private Boolean uppercase = false;
160+
157161
@OneToMany(mappedBy = "migration")
158162
@OrderBy("id ASC")
159163
private Set<MigrationHistory> histories = new HashSet<>();
@@ -542,6 +546,14 @@ public void setCleaning(Boolean cleaning) {
542546
this.cleaning = cleaning;
543547
}
544548

549+
public Boolean getUppercase() {
550+
return uppercase;
551+
}
552+
553+
public void setUppercase(Boolean uppercase) {
554+
this.uppercase = uppercase;
555+
}
556+
545557
public String getUploadType() { return uploadType; }
546558

547559
public void setUploadType(String uploadType) { this.uploadType = uploadType; }

src/main/java/fr/yodamad/svn2git/domain/SvnStructure.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public class SvnStructure {
1616
public boolean flat = false;
1717
/** Flag for classic repository at root level. */
1818
public boolean root = false;
19+
/** Flag to indicate that keywords are in uppercase. */
20+
public boolean uppercase = false;
1921
/** SVN modules. */
2022
public List<SvnModule> modules = new ArrayList<>();
2123

@@ -45,7 +47,8 @@ public static class SvnModule extends SvnStructure {
4547
public String path;
4648
/** Potential submodules. */
4749
public List<SvnModule> subModules = new ArrayList<>();
48-
/** Flag for flat module (no trunk, tags or branches) **/
50+
/** Flag to indicate that keywords are in uppercase. */
51+
public boolean uppercase = false;
4952

5053
public SvnModule(String name, String path) {
5154
super(name);

src/main/kotlin/fr/yodamad/svn2git/functions/GitFunctions.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,12 @@ fun isFileInFolder(dirPath: String): Boolean {
212212

213213
fun buildTrunk(workUnit: WorkUnit): String? {
214214
val mig = workUnit.migration
215+
val trunk = if (workUnit.migration.uppercase) "TRUNK" else "trunk"
215216
return if (mig.flat) {
216217
if (mig.svnGroup == mig.svnProject) {
217218
"--trunk=/"
218219
} else String.format("--trunk=%s/", workUnit.migration.svnProject.encode())
219-
} else String.format("--trunk=%s/trunk", workUnit.migration.svnProject.encode())
220+
} else String.format("--trunk=%s/%s", workUnit.migration.svnProject.encode(), trunk)
220221
}
221222

222223
fun buildSvnCompleteUrl(workUnit: WorkUnit) =

src/main/kotlin/fr/yodamad/svn2git/service/Cleaner.kt

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ open class Cleaner(val historyMgr: HistoryManager,
8686
val gitCommand = String.format("git checkout -b \"%s\" \"%s\"", branchName, b)
8787
execCommand(workUnit.commandManager, workUnit.directory, gitCommand)
8888
// listCleanedFilesInSvnLocation
89-
val cleanedFilesBranch: CleanedFiles = listCleanedFilesInSvnLocation(workUnit, b.replace("origin", "branches"), SvnLayout.BRANCH)
90-
cleanedFilesMap[b.replace("origin", "branches")] = cleanedFilesBranch
89+
val branches = if (workUnit.migration.uppercase) "branches".toUpperCase() else "branches"
90+
val cleanedFilesBranch: CleanedFiles = listCleanedFilesInSvnLocation(workUnit, b.replace("origin", branches), SvnLayout.BRANCH)
91+
cleanedFilesMap[b.replace("origin", branches)] = cleanedFilesBranch
9192
// clean potential modification
9293
execCommand(workUnit.commandManager, workUnit.directory, resetHead())
9394
// back to master
@@ -110,8 +111,9 @@ open class Cleaner(val historyMgr: HistoryManager,
110111
val gitCommand = String.format("git checkout -b tmp_tag \"%s\"", t)
111112
execCommand(workUnit.commandManager, workUnit.directory, gitCommand)
112113
// listCleanedFilesInSvnLocation
113-
val cleanedFilesTag: CleanedFiles = listCleanedFilesInSvnLocation(workUnit, t.replace("origin", "tags"), TAG)
114-
cleanedFilesMap[t.replace("origin", "tags")] = cleanedFilesTag
114+
val tags = if (workUnit.migration.uppercase) "tags".toUpperCase() else "tags"
115+
val cleanedFilesTag: CleanedFiles = listCleanedFilesInSvnLocation(workUnit, t.replace("origin", tags), TAG)
116+
cleanedFilesMap[t.replace("origin", tags)] = cleanedFilesTag
115117
// clean potential modification
116118
execCommand(workUnit.commandManager, workUnit.directory, resetHead())
117119
// back to master
@@ -388,8 +390,8 @@ open class Cleaner(val historyMgr: HistoryManager,
388390
*/
389391
open fun cleanElementsOn(workUnit: WorkUnit, tags: Boolean) {
390392

391-
val elements = if (tags) Pair(workUnit.migration.tags, "tags")
392-
else Pair(workUnit.migration.branches, "branches")
393+
val elements = if (tags) Pair(workUnit.migration.tags, if (workUnit.migration.uppercase) "tags".toUpperCase() else "tags")
394+
else Pair(workUnit.migration.branches, if (workUnit.migration.uppercase) "branches".toUpperCase() else "branches")
393395

394396
if (elements.first != null) {
395397
val history = historyMgr.startStep(workUnit.migration, StepEnum.BRANCH_CLEAN, "Clean removed SVN ${elements.second}")
@@ -430,7 +432,7 @@ open class Cleaner(val historyMgr: HistoryManager,
430432
Files.readAllLines(Paths.get(workUnit.directory, GIT_LIST))
431433
.stream()
432434
.map { l: String -> l.trim { it <= ' ' }.replace("origin/", "").decode().encode() }
433-
.filter { t: String -> t.startsWith("tags") }
435+
.filter { t: String -> t.startsWith("tags") || t.startsWith("TAGS") }
434436
.map { l: String -> l.replace(TAGS, "") }
435437
.filter { l: String -> !l.equals(workUnit.migration.trunk, ignoreCase = true) }
436438
.collect(Collectors.toList())
@@ -461,12 +463,12 @@ open class Cleaner(val historyMgr: HistoryManager,
461463
val svnUrl = if (workUnit.migration.svnUrl.endsWith("/")) workUnit.migration.svnUrl else String.format("%s/", workUnit.migration.svnUrl)
462464
val svnBranchList: String = if (StringUtils.isEmpty(workUnit.migration.svnPassword)) {
463465
String.format("svn ls %s%s%s/%s > %s", svnUrl, workUnit.migration.svnGroup, workUnit.migration.svnProject,
464-
if (isTags) "tags" else "branches", SVN_LIST)
466+
if (isTags && workUnit.migration.uppercase) "tags".toUpperCase() else if (isTags) "tags" else if (workUnit.migration.uppercase) "branches".toUpperCase() else "branches", SVN_LIST)
465467
} else {
466468
String.format("svn ls %s%s%s/%s %s %s > %s", svnUrl,
467469
if (workUnit.migration.svnGroup.endsWith("/")) workUnit.migration.svnGroup else String.format("%s/", workUnit.migration.svnGroup),
468470
workUnit.migration.svnProject,
469-
if (isTags) "tags" else "branches",
471+
if (isTags && workUnit.migration.uppercase) "tags".toUpperCase() else if (isTags) "tags" else if (workUnit.migration.uppercase) "branches".toUpperCase() else "branches",
470472
"--username=" + workUnit.migration.svnUser, "--password=" + workUnit.migration.svnPassword.escape(),
471473
SVN_LIST)
472474
}
@@ -491,13 +493,13 @@ open class Cleaner(val historyMgr: HistoryManager,
491493
gitElementsToDelete.forEach(Consumer { line: String ->
492494
try {
493495
var cleanCmd = String.format("git branch -d -r %s", String.format("\"origin/%s%s\"",
494-
if (isTags && !line.startsWith("tags")) TAGS else "", line))
496+
if (isTags && (!line.startsWith("tags") || !line.startsWith("TAGS"))) TAGS else "", line))
495497
execCommand(workUnit.commandManager, workUnit.directory, cleanCmd)
496498
cleanCmd = if (Shell.isWindows) {
497499
String.format("rd /s /q \".git\\svn\\refs\\remotes\\origin\\%s\\\"", String.format("%s%s", if (isTags) "tags\\" else "", line))
498500
} else {
499501
String.format("rm -rf %s", String.format("\".git/svn/refs/remotes/origin/%s%s\"",
500-
if (isTags && !line.startsWith("tags")) TAGS else "", line))
502+
if (isTags && (!line.startsWith("tags") || !line.startsWith("TAGS"))) TAGS else "", line))
501503
}
502504
execCommand(workUnit.commandManager, workUnit.directory, cleanCmd)
503505
} catch (ex: IOException) {

src/main/kotlin/fr/yodamad/svn2git/service/util/GitCommandManager.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,11 @@ open class GitCommandManager(val historyMgr: HistoryManager,
110110
/**
111111
* Set element (branch or tag)
112112
*/
113-
private fun setSvnElement(elementName: String, element: String?, workUnit: WorkUnit) =
114-
if (element == null) EMPTY
115-
else "--$elementName=${workUnit.migration.svnProject}/$elementName"
113+
private fun setSvnElement(elementName: String, element: String?, workUnit: WorkUnit): String {
114+
val elt = if (workUnit.migration.uppercase) elementName.toUpperCase() else elementName
115+
return if (element == null) EMPTY
116+
else "--$elementName=${workUnit.migration.svnProject}/$elt"
117+
}
116118

117119
/**
118120
* Build command to add remote

src/main/kotlin/fr/yodamad/svn2git/web/rest/SvnResource.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ open class SvnResource(val applicationProperties: ApplicationProperties) {
3434
/** Logger. */
3535
private val log = LoggerFactory.getLogger(SvnResource::class.java)
3636

37+
lateinit var structure: SvnStructure
38+
3739
/**
3840
* Check if a SVN repository
3941
* @param repositoryName SVN repository ID search
@@ -61,10 +63,11 @@ open class SvnResource(val applicationProperties: ApplicationProperties) {
6163
*/
6264
protected open fun listSVN(svnInfo: SvnInfo, repo: String?, depth: Int?): SvnStructure {
6365
val depthOrDefault = depth ?: 1
64-
val structure = SvnStructure(repo)
66+
structure = SvnStructure(repo)
6567
structure.modules = listModulesSVN(svnInfo, repo, null, 0, depthOrDefault)
6668
if (structure.modules.stream().anyMatch { m: SvnModule? -> m is FakeModule }) {
6769
structure.root = true
70+
structure.uppercase = structure.modules.first().uppercase
6871
structure.modules.clear()
6972
}
7073
structure.flat = structure.modules.isEmpty()
@@ -118,7 +121,7 @@ open class SvnResource(val applicationProperties: ApplicationProperties) {
118121
val modulesFounds: MutableList<SvnModule> = ArrayList()
119122
list.receiver = ISvnObjectReceiver { _, `object`: SVNDirEntry ->
120123
val name = `object`.relativePath
121-
if (name != null && !name.isEmpty() && !keywords().contains(name.toLowerCase()) && module?.layoutElements.isNullOrEmpty()) {
124+
if (name != null && name.isNotEmpty() && !keywords().contains(name.toLowerCase()) && module?.layoutElements.isNullOrEmpty()) {
122125

123126
// found a directory
124127
if (`object`.kind == SVNNodeKind.DIR) {
@@ -136,15 +139,18 @@ open class SvnResource(val applicationProperties: ApplicationProperties) {
136139
modulesFounds.clear()
137140
}
138141
}
139-
if (name != null && !name.isEmpty() && keywords().contains(name)) {
142+
if (name != null && name.isNotEmpty() && keywords().contains(name.toLowerCase())) {
140143
if (module != null) {
141144
log.info(String.format("Module %s with layout %s", module.name, name))
142145
module.layoutElements.add(name)
143146
module.flat = false
144147
modulesFounds.clear()
145148
} else {
146149
// Root level case
147-
modulesFounds.add(FakeModule())
150+
val fake = FakeModule()
151+
// Check uppercase
152+
fake.uppercase = name.toUpperCase() == name
153+
modulesFounds.add(fake)
148154
}
149155
}
150156
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<databaseChangeLog
3+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
4+
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd
7+
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
8+
9+
<property name="now" value="now()" dbms="h2"/>
10+
<property name="now" value="now()" dbms="mysql"/>
11+
<property name="autoIncrement" value="true"/>
12+
13+
<changeSet id="uppercase" author="mvt">
14+
15+
<addColumn tableName="migration">
16+
<column name="uppercase" type="boolean">
17+
<constraints nullable="true" />
18+
</column>
19+
</addColumn>
20+
21+
</changeSet>
22+
23+
</databaseChangeLog>

src/main/resources/config/liquibase/master.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@
2929
<include file="config/liquibase/changelog/2021030122350000_added_Migration_upload_type.xml" relativeToChangelogFile="false"/>
3030
<include file="config/liquibase/changelog/2021031721150000_added_Migration_emptydirs_column.xml" relativeToChangelogFile="false"/>
3131
<include file="config/liquibase/changelog/2021120612150000_added_Migration_cleaning_column.xml" relativeToChangelogFile="false"/>
32+
<include file="config/liquibase/changelog/202121423150000_added_Migration_uppercase_column.xml" relativeToChangelogFile="false"/>
3233

3334
</databaseChangeLog>

src/main/webapp/app/migration/migration-process.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class SvnInfo {
107107
}
108108

109109
export class SvnStructure {
110-
constructor(public name: string, public flat: boolean, public root: boolean, public modules: SvnModule[]) {}
110+
constructor(public name: string, public flat: boolean, public root: boolean, public uppercase: boolean, public modules: SvnModule[]) {}
111111
}
112112

113113
export class SvnModule {
@@ -116,7 +116,8 @@ export class SvnModule {
116116
public name: string,
117117
public path: string,
118118
public subModules: SvnModule[],
119-
public flat: boolean
119+
public flat: boolean,
120+
public uppercase: boolean
120121
) {}
121122
}
122123

0 commit comments

Comments
 (0)