From a4b8f4050478409feb3d4d1e07ab96f529a3941e Mon Sep 17 00:00:00 2001 From: Lars Windauer Date: Tue, 18 Jan 2022 19:21:59 +0100 Subject: [PATCH] bugfix release v.1.0.2 --- README.md | 2 +- package.json | 2 +- src/api.json | 2 +- src/expath-pkg.xml | 2 +- src/modules/api.xql | 27 ++++++++++----------------- src/modules/github.xql | 12 +++--------- src/modules/gitlab.xql | 8 +------- 7 files changed, 18 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index cfdeae1..b4a717d 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Synchronizes your data collection with GitHub and GitLab. ## Current restrictions -In version 1.0.1 not implemented: +In version 1.0.2 not implemented: - webhooks are not fully implemented. ## Building and Installation diff --git a/package.json b/package.json index ce12095..4ab64cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tuttle", - "version": "1.0.1", + "version": "1.0.2", "description": "tuttle - a Git-integration for eXist-db", "scripts": { "test": "gulp install && mocha --exit", diff --git a/src/api.json b/src/api.json index e283469..9f287fb 100644 --- a/src/api.json +++ b/src/api.json @@ -1,7 +1,7 @@ { "openapi": "3.0.0", "info": { - "version": "1.0.1", + "version": "1.0.2", "title": "Tuttle API", "description": "API for Tuttle Git integration" }, diff --git a/src/expath-pkg.xml b/src/expath-pkg.xml index 706e300..382211e 100644 --- a/src/expath-pkg.xml +++ b/src/expath-pkg.xml @@ -2,7 +2,7 @@ + abbrev="tuttle" version="1.0.2" spec="1.0"> Tuttle - Git for eXist-db diff --git a/src/modules/api.xql b/src/modules/api.xql index 2aadcbe..27f9dde 100644 --- a/src/modules/api.xql +++ b/src/modules/api.xql @@ -196,9 +196,16 @@ declare function api:git-deploy($request as map(*)) { return if (exists($config)) then ( try { - if (xmldb:collection-available($collection-staging)) then ( - if (xmldb:collection-available($collection-staging-uri)) then ( - if (not(exists(doc($lockfile)))) then ( + if (not(xmldb:collection-available($collection-destination))) then ( + map { "message" : "Destination collection '" || $collection-destination || "' does not exist" } + ) + else if (not(xmldb:collection-available($collection-staging-uri))) then ( + map { "message" : "Staging collection '" || $collection-staging || "' does not exist" } + ) + else if (exists(doc($lockfile))) then ( + map { "message" : doc($lockfile)/task/value/text() || " in progress" } + ) + else ( let $write-lock := app:lock-write($collection-destination, "deploy") let $pre-install := if ($request?parameters?pre-install) then config:pre-install($collection-destination,$collection-staging-uri) @@ -214,20 +221,6 @@ declare function api:git-deploy($request as map(*)) { map { "sha" : app:production-sha($git-collection), "message" : "success" - }) - else - let $message := doc($lockfile)/task/value/text() || " in progress" - return - map { "message" : $message} - ) - else ( - map { "message" : "staging collction not exist" - } - ) - ) - else ( - map { - "message" : "Destination collection not exist" } ) } diff --git a/src/modules/github.xql b/src/modules/github.xql index ed08e09..0fe3c02 100644 --- a/src/modules/github.xql +++ b/src/modules/github.xql @@ -24,7 +24,6 @@ declare function github:clone($config as map(*), $collection as xs:string, $sha "message" : concat($config?vcs, " error: ", github:request($url, $config?token)[1]/xs:string(@message)) } ) else ( - if (github:available-sha($config, $sha)) then ( let $request := github:request($url, $config?token) let $filter := app:unzip-filter#3 let $unzip-action := app:unzip-store#4 @@ -35,18 +34,13 @@ declare function github:clone($config as map(*), $collection as xs:string, $sha xmldb:remove($collection) else () let $create-collection := xmldb:create-collection("/", $collection) - let $wirte-sha := app:write-sha($collection,$sha) + let $write-sha := app:write-sha($collection, github:get-lastcommit-sha($config)?sha) + let $clone := compression:unzip ($request[2], $filter, $filter-params, $unzip-action, $data-params) return map { "message" : "Success" } ) - else ( - map { - "message" : "REF not exist" - } - ) - ) } catch * { map { @@ -102,7 +96,7 @@ declare function github:get-commits($config as map(*), $count as xs:int) { : Get all commits in full sha lenght :) declare function github:get-commits-fullsha($config as map(*)) { - let $url := $config?baseurl || "/repos/" || $config?owner || "/" || $config?repo || "/commits?sha=" || $config?refss + let $url := $config?baseurl || "/repos/" || $config?owner || "/" || $config?repo || "/commits?sha=" || $config?ref let $request := parse-json(util:base64-decode(github:request($url, $config?token)[2])) diff --git a/src/modules/gitlab.xql b/src/modules/gitlab.xql index 3809b29..3606e8a 100644 --- a/src/modules/gitlab.xql +++ b/src/modules/gitlab.xql @@ -22,7 +22,6 @@ declare function gitlab:clone($config as map(*), $collection as xs:string, $sha "message" : concat($config?vcs, " error: ", gitlab:request($url, $config?token)[1]/xs:string(@message)) } ) else ( - if (gitlab:available-sha($config, $sha)) then ( let $request := gitlab:request($url, $config?token) let $filter := app:unzip-filter#3 let $unzip-action := app:unzip-store#4 @@ -33,16 +32,11 @@ declare function gitlab:clone($config as map(*), $collection as xs:string, $sha xmldb:remove($collection) else () let $create-collection := xmldb:create-collection("/", $collection) - let $wirte-sha := app:write-sha($collection,$sha) + let $write-sha := app:write-sha($collection, gitlab:get-lastcommit-sha($config)?sha) let $clone := compression:unzip ($request[2], $filter, $filter-params, $unzip-action, $data-params) return map { "message" : "Success" } - ) - else ( - map { - "message" : "REF not exist" - } ) ) }