Skip to content

Commit

Permalink
Related to #144 Summer cleaning before fixing context shenanigans
Browse files Browse the repository at this point in the history
  • Loading branch information
Thierry Lacour committed Jul 30, 2018
1 parent f372a37 commit ffefbb5
Show file tree
Hide file tree
Showing 43 changed files with 115 additions and 268 deletions.
18 changes: 8 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# Gradle
# dev
.gradle
build/
gradle-app.setting
!gradle-wrapper.jar
/.nb-gradle/

# IDEA
bin/
.project
.settings
.classpath

.vscode

.idea/
*.iml

# Output
out/

# Jekyll
_site
.sass-cache

Expand All @@ -22,8 +25,3 @@ _site
# Specific command files
customers/*
*.swp

# 2git log files
2git-[-_0-9]*.log
logs
cc2git
13 changes: 0 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,3 @@ github {

githubRelease.group = "Publishing"
githubRelease.description = "Creates a release on GitHub"

// --------------------
// testing
// --------------------

task functionalTest(type: Test) {
dependsOn('testClasses')
include 'toGit/functional/**'
}

test {
exclude 'toGit/functional/**'
}
13 changes: 5 additions & 8 deletions src/main/groovy/toGit/ScriptBase.groovy
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package toGit

import org.slf4j.LoggerFactory
import toGit.context.MigrationContext
import toGit.context.base.Context
import toGit.context.base.DslContext
import toGit.context.traits.SourceContext
import toGit.context.traits.TargetContext
import toGit.context.*
import toGit.context.*
import toGit.migration.MigrationManager
import toGit.migration.sources.MigrationSource
import toGit.migration.sources.ccbase.context.ClearCaseSourceContext
Expand Down Expand Up @@ -71,9 +68,9 @@ abstract class ScriptBase extends Script implements Context {
if (!sourceTypes.containsKey(type)) throw new Exception("Source '$type' not supported.")

// Initialize and configure the source
def sourceContext = sourceTypes[type].newInstance() as SourceContext
executeInContext(closure, sourceContext)
MigrationSource newSource = sourceContext.source
def SourceContext = sourceTypes[type].newInstance()
executeInContext(closure, SourceContext)
MigrationSource newSource = SourceContext.source

// Set MigrationManager's source
MigrationManager.instance.source = newSource
Expand Down
6 changes: 3 additions & 3 deletions src/main/groovy/toGit/context/ActionsContext.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import groovy.text.SimpleTemplateEngine
import net.praqma.util.execute.CommandLine
import org.apache.commons.io.FileUtils
import org.slf4j.LoggerFactory
import toGit.context.base.Context
import toGit.context.traits.HasActions
import toGit.migration.MigrationManager
import toGit.migration.plan.Action
import toGit.utils.FileHelper

class ActionsContext implements Context, HasActions {
class ActionsContext implements Context {

final static log = LoggerFactory.getLogger(this.class)

final List<Action> actions = []

/**
* Copies the contents of the source directory to the default target directory.
*/
Expand Down
2 changes: 0 additions & 2 deletions src/main/groovy/toGit/context/AfterContext.groovy
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package toGit.context

import org.slf4j.LoggerFactory
import toGit.context.base.Context
import toGit.context.base.DslContext
import toGit.migration.MigrationManager

import static ContextHelper.executeInContext
Expand Down
2 changes: 0 additions & 2 deletions src/main/groovy/toGit/context/BeforeContext.groovy
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package toGit.context

import org.slf4j.LoggerFactory
import toGit.context.base.Context
import toGit.context.base.DslContext
import toGit.migration.MigrationManager

import static toGit.context.ContextHelper.executeInContext
Expand Down
3 changes: 3 additions & 0 deletions src/main/groovy/toGit/context/Context.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package toGit.context

interface Context {}
11 changes: 3 additions & 8 deletions src/main/groovy/toGit/context/ContextHelper.groovy
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package toGit.context

import toGit.context.base.Context
import toGit.context.traits.HasActions
import toGit.context.traits.HasCriteria
import toGit.context.traits.HasExtractions

class ContextHelper {
private ContextHelper() {
}
Expand All @@ -19,9 +14,9 @@ class ContextHelper {
if (closure) {
//FIXME Workaround for the CEA arrays not being cleared
//FIXME This is due to contexts being global and no new instances being made
if (context instanceof HasCriteria) context.criteria.clear()
if (context instanceof HasExtractions) context.extractions.clear()
if (context instanceof HasActions) context.actions.clear()
if (context instanceof CriteriaContext) context.criteria.clear()
if (context instanceof ExtractionsContext) context.extractions.clear()
if (context instanceof ActionsContext) context.actions.clear()

closure.delegate = context
closure.resolveStrategy = Closure.DELEGATE_FIRST
Expand Down
6 changes: 3 additions & 3 deletions src/main/groovy/toGit/context/CriteriaContext.groovy
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package toGit.context

import org.slf4j.LoggerFactory
import toGit.context.base.Context
import toGit.context.traits.HasCriteria
import toGit.migration.plan.Criteria
import toGit.migration.plan.Snapshot

class CriteriaContext implements Context, HasCriteria {
class CriteriaContext implements Context {

final static log = LoggerFactory.getLogger(this.class)

final List<Criteria> criteria = []

/**
* Filters {@link Snapshot}s using a custom Groovy closure
* @param closure Closure to run
Expand Down
5 changes: 5 additions & 0 deletions src/main/groovy/toGit/context/DslContext.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package toGit.context

@interface DslContext {
Class<? extends Context> value()
}
6 changes: 3 additions & 3 deletions src/main/groovy/toGit/context/ExtractionsContext.groovy
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package toGit.context

import org.slf4j.LoggerFactory
import toGit.context.base.Context
import toGit.context.traits.HasExtractions
import toGit.migration.plan.Extraction
import toGit.migration.plan.Snapshot

class ExtractionsContext implements Context, HasExtractions {
class ExtractionsContext implements Context {

final static log = LoggerFactory.getLogger(this.class)

final List<Extraction> extractions = []

/**
* Runs a custom closure to map values
* @param closure Closure to run
Expand Down
2 changes: 0 additions & 2 deletions src/main/groovy/toGit/context/FilterContext.groovy
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package toGit.context

import org.slf4j.LoggerFactory
import toGit.context.base.Context
import toGit.context.base.DslContext
import toGit.migration.MigrationManager
import toGit.migration.plan.Filter

Expand Down
2 changes: 0 additions & 2 deletions src/main/groovy/toGit/context/FiltersContext.groovy
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package toGit.context

import org.slf4j.LoggerFactory
import toGit.context.base.Context
import toGit.context.base.DslContext
import toGit.migration.plan.Filter

import static ContextHelper.executeInContext
Expand Down
2 changes: 0 additions & 2 deletions src/main/groovy/toGit/context/MigrationContext.groovy
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package toGit.context

import org.slf4j.LoggerFactory
import toGit.context.base.Context
import toGit.context.base.DslContext
import toGit.migration.MigrationManager

import static ContextHelper.executeInContext
Expand Down
7 changes: 7 additions & 0 deletions src/main/groovy/toGit/context/SourceContext.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package toGit.context

import toGit.migration.sources.MigrationSource

abstract class SourceContext implements Context {
MigrationSource source
}
7 changes: 7 additions & 0 deletions src/main/groovy/toGit/context/TargetContext.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package toGit.context

import toGit.migration.targets.MigrationTarget

abstract class TargetContext implements Context {
MigrationTarget target
}
4 changes: 0 additions & 4 deletions src/main/groovy/toGit/context/base/Context.groovy

This file was deleted.

15 changes: 0 additions & 15 deletions src/main/groovy/toGit/context/base/DslContext.groovy

This file was deleted.

8 changes: 0 additions & 8 deletions src/main/groovy/toGit/context/traits/HasActions.groovy

This file was deleted.

8 changes: 0 additions & 8 deletions src/main/groovy/toGit/context/traits/HasCriteria.groovy

This file was deleted.

8 changes: 0 additions & 8 deletions src/main/groovy/toGit/context/traits/HasExtractions.groovy

This file was deleted.

8 changes: 0 additions & 8 deletions src/main/groovy/toGit/context/traits/SourceContext.groovy

This file was deleted.

8 changes: 0 additions & 8 deletions src/main/groovy/toGit/context/traits/TargetContext.groovy

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/groovy/toGit/migration/MigrationManager.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.slf4j.LoggerFactory
import toGit.context.ActionsContext
import toGit.context.CriteriaContext
import toGit.context.ExtractionsContext
import toGit.context.base.Context
import toGit.context.Context
import toGit.migration.plan.MigrationPlan
import toGit.migration.sources.MigrationSource
import toGit.migration.targets.MigrationTarget
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package toGit.migration.sources

import toGit.context.base.Context
import toGit.context.Context
import toGit.migration.plan.Criteria
import toGit.migration.plan.Snapshot

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package toGit.migration.sources.ccbase

import org.slf4j.LoggerFactory
import toGit.context.base.Context
import toGit.context.Context
import toGit.migration.plan.Criteria
import toGit.migration.plan.Snapshot
import toGit.migration.sources.MigrationSource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package toGit.migration.sources.ccbase.context

import org.slf4j.Logger
import org.slf4j.LoggerFactory
import toGit.context.base.Context
import toGit.context.Context
import toGit.migration.sources.ccbase.criteria.AfterLabel
import toGit.migration.sources.ccbase.criteria.LabelName

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package toGit.migration.sources.ccbase.context

import org.slf4j.Logger
import org.slf4j.LoggerFactory
import toGit.context.base.Context
import toGit.context.Context
import toGit.migration.sources.ccbase.extractions.LabelExtraction

trait ClearCaseExtractionsContext implements Context {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package toGit.migration.sources.ccbase.context

import org.slf4j.LoggerFactory
import toGit.context.base.Context
import toGit.context.traits.SourceContext
import toGit.context.SourceContext
import toGit.migration.sources.ccbase.ClearCaseSource

class ClearCaseSourceContext implements Context, SourceContext {
class ClearCaseSourceContext extends SourceContext {
final static log = LoggerFactory.getLogger(this.class)

public ClearCaseSourceContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import net.praqma.clearcase.ucm.entities.Stream as CoolStream
import net.praqma.clearcase.ucm.utils.BaselineFilter
import net.praqma.clearcase.ucm.view.SnapshotView as CoolSnapshotView
import org.slf4j.LoggerFactory
import toGit.context.base.Context
import toGit.context.Context
import toGit.migration.plan.Criteria
import toGit.migration.plan.Snapshot
import toGit.migration.sources.MigrationSource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package toGit.migration.sources.ccucm.context
import net.praqma.clearcase.ucm.entities.Baseline as CoolBaseline
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import toGit.context.base.Context
import toGit.context.Context
import toGit.migration.sources.ccucm.criteria.AfterDate
import toGit.migration.sources.ccucm.criteria.BaselineName
import toGit.migration.sources.ccucm.criteria.BaselineNames
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package toGit.migration.sources.ccucm.context

import org.slf4j.Logger
import org.slf4j.LoggerFactory
import toGit.context.base.Context
import toGit.context.Context
import toGit.migration.sources.ccucm.extractions.BaselineProperty

trait CcucmExtractionsContext implements Context {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ package toGit.migration.sources.ccucm.context

import net.praqma.clearcase.ucm.view.SnapshotView
import org.slf4j.LoggerFactory
import toGit.context.base.Context
import toGit.context.traits.SourceContext
import toGit.context.SourceContext
import toGit.migration.sources.ccucm.CcucmOptions
import toGit.migration.sources.ccucm.CcucmSource

class CcucmSourceContext implements Context, SourceContext {
class CcucmSourceContext extends SourceContext {

final static log = LoggerFactory.getLogger(this.class)

Expand Down
Loading

0 comments on commit ffefbb5

Please sign in to comment.