Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed plugin registration to create a new assembly, if major/minor version was bumped #79

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions src/Delegate.Daxif/Modules/Plugins/Compare.fs
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,21 @@ let image (img: Image) (x: Entity) =

/// Compares an assembly from CRM with the one containing the source code
/// Returns true if the assembly in CRM is newer and the hash matches the one in the source code
let registeredIsSameAsLocal (local: AssemlyLocal) (registered: AssemblyRegistration option) =
registered
?|> fun y ->
let log = ConsoleLogger.Global

let environmentIsNewer = y.version .>= local.version
log.Verbose "Registered version %s is %s than local version %s"
(y.version |> versionToString) (if environmentIsNewer then "newer" else "older") (local.version |> versionToString)

let hashMatch = y.hash = local.hash
log.Verbose "Registered assembly hash %s local assembly hash" (if hashMatch then "matches" else "does not match")
let registeredIsSameAsLocal (local: AssemlyLocal) (registered: AssemblyRegistration) =
let log = ConsoleLogger.Global

let isSameAssembly = environmentIsNewer && hashMatch
log.Verbose "Assembly will%s be updated" (if isSameAssembly then " not" else "")
let environmentIsNewer = registered.version .>= local.version
log.Verbose "Registered version %s is %s than local version %s"
(registered.version |> versionToString) (if environmentIsNewer then "newer" else "older") (local.version |> versionToString)

isSameAssembly
?| false
let hashMatch = registered.hash = local.hash
log.Verbose "Registered assembly hash %s local assembly hash" (if hashMatch then "matches" else "does not match")

let isSameAssembly = environmentIsNewer && hashMatch
log.Verbose "Assembly will%s be updated" (if isSameAssembly then " not" else "")

let majorMinorUpdate =
(local.version, registered.version)
|> fun ((a1, b1, _, _), (a2, b2, _, _)) -> a1 > a2 || (a1 = a2 && b1 > b2)

isSameAssembly, majorMinorUpdate
7 changes: 5 additions & 2 deletions src/Delegate.Daxif/Modules/Plugins/MainHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ let localToMaps (plugins: Plugin seq) (customAPIs: CustomAPI seq) =
/// Determine which operation we want to perform on the assembly
let determineOperation (asmReg: AssemblyRegistration option) (asmLocal) : AssemblyOperation * Guid =
match asmReg with
| Some asm when Compare.registeredIsSameAsLocal asmLocal (Some asm) -> Unchanged, asm.id
| Some asm -> Update, asm.id
| Some asm ->
match Compare.registeredIsSameAsLocal asmLocal asm with
| true, _ -> Unchanged, asm.id
| false, false -> Update, asm.id
| false, true -> Create, Guid.Empty
| None -> Create, Guid.Empty

/// Update or create assembly
Expand Down