From 01848455389c5b3b24bbb75af1e621908dc6aa7b Mon Sep 17 00:00:00 2001 From: Carlos Mecha Date: Wed, 11 Jul 2018 13:26:01 -0700 Subject: [PATCH 1/9] Fix latest tag --- operations/git.go | 63 ++++++++++++++++++++++++++++------- operations/integrationrepo.go | 5 ++- 2 files changed, 53 insertions(+), 15 deletions(-) diff --git a/operations/git.go b/operations/git.go index 75105daa9..b31c907ab 100644 --- a/operations/git.go +++ b/operations/git.go @@ -7,6 +7,15 @@ import ( "gopkg.in/libgit2/git2go.v27" ) +// Tag is an annotated or lightweight tag +type Tag struct { + Name string + When time.Time + IsAnnotated bool + Tag *git.Tag // for annotated + Commit *git.Commit // for lightweight +} + // printMessage is the default "print" callback func printMessage(msg string) git.ErrorCode { Debug("Message %s", msg) @@ -126,9 +135,14 @@ func getLocalHead(repo *git.Repository) (*git.Commit, error) { return head, nil } -// getLatestTag retrieves the last *SIGNED* tag. In some situations this is not the latest tag +func GetLatestTag(repo *git.Repository) (*Tag, error) { + return getLatestTag(repo) +} + +// getLatestTag retrieves the last tag. In some situations this is not the latest tag // in the master branch. If not tags are found, it will return nil. -func getLatestTag(repo *git.Repository) (*git.Tag, error) { +// For lightweigh tags, it will return the empty struct with the name only. +func getLatestTag(repo *git.Repository) (*Tag, error) { tagNames, err := repo.Tags.List() if err != nil { @@ -136,22 +150,15 @@ func getLatestTag(repo *git.Repository) (*git.Tag, error) { return nil, err } - var latestTag *git.Tag + var latestTag *Tag for _, name := range tagNames { - reference, err := repo.References.Lookup("refs/tags/" + name) + tag, err := resolveTag(repo, name) if err != nil { - LogError(err, "Error getting reference for tag %s", name) return nil, err } - tag, err := repo.LookupTag(reference.Target()) - if err != nil { - LogError(err, "Error getting tag %s", name) - return nil, err - } - - if latestTag == nil || latestTag.Tagger().When.Before(tag.Tagger().When) { + if latestTag == nil || latestTag.When.Before(tag.When) { latestTag = tag } } @@ -159,6 +166,38 @@ func getLatestTag(repo *git.Repository) (*git.Tag, error) { return latestTag, nil } +// resolveTag retrieves the tag using the name +func resolveTag(repo *git.Repository, name string) (*Tag, error) { + reference, err := repo.References.Lookup("refs/tags/" + name) + if err != nil { + LogError(err, "Error getting reference for tag %s", name) + return nil, err + } + + tag, err := repo.LookupTag(reference.Target()) + if err == nil { + return &Tag{ + Name: tag.Name(), + When: tag.Tagger().When, + IsAnnotated: true, + Tag: tag, + }, nil + } + + // Lightweight tag or reference + commit, err := repo.LookupCommit(reference.Target()) + if err != nil { + LogError(err, "The tag %s is not an annotated tag or references a commit", name) + return nil, err + } + + return &Tag{ + Name: name, + When: commit.Committer().When, + Commit: commit, + }, nil +} + // getSignature returns the default signature unless the env vars GITHUB_USER // and GITHUB_EMAIL are present. func getSignature(repo *git.Repository) (*git.Signature, error) { diff --git a/operations/integrationrepo.go b/operations/integrationrepo.go index 28ad770c7..5d5cbcfde 100644 --- a/operations/integrationrepo.go +++ b/operations/integrationrepo.go @@ -275,13 +275,12 @@ func (i *IntegrationRepo) notify(monorepo Monorepo, commitLink string) error { lastTag, err := getLatestTag(i.Repo) if err != nil { - // Let's ignore for now. - //return err + return err } var lastTagName string if lastTag != nil { - lastTagName = lastTag.Name() + lastTagName = lastTag.Name } if err := i.updateReadme(commitLink, lastTagName); err != nil { From 4c8fc1ecb5a1d63968d38bbbe09564aad412fd7c Mon Sep 17 00:00:00 2001 From: SegmentDestinationsBot Date: Wed, 11 Jul 2018 13:27:47 -0700 Subject: [PATCH 2/9] Add integration criteo This commit copies the content of the integration repo into the "integrations" folder. Original repo: https://github.com/segment-integrations/analytics.js-integration-criteo Readme: https://github.com/segment-integrations/analytics.js-integration-criteo/blob/master/README.md --- integrations/criteo/HISTORY.md | 40 + integrations/criteo/README.md | 8 + integrations/criteo/lib/index.js | 238 ++ integrations/criteo/package.json | 61 + integrations/criteo/test/.eslintrc | 3 + integrations/criteo/test/index.test.js | 250 ++ integrations/criteo/yarn.lock | 5309 ++++++++++++++++++++++++ 7 files changed, 5909 insertions(+) create mode 100644 integrations/criteo/HISTORY.md create mode 100644 integrations/criteo/README.md create mode 100644 integrations/criteo/lib/index.js create mode 100644 integrations/criteo/package.json create mode 100644 integrations/criteo/test/.eslintrc create mode 100644 integrations/criteo/test/index.test.js create mode 100644 integrations/criteo/yarn.lock diff --git a/integrations/criteo/HISTORY.md b/integrations/criteo/HISTORY.md new file mode 100644 index 000000000..06cab270c --- /dev/null +++ b/integrations/criteo/HISTORY.md @@ -0,0 +1,40 @@ +1.1.0 / 2017-08-29 +================== + + * Update handling of extraData events. + +1.0.6 / 2017-08-22 +================== + + * Support both http/https. + +1.0.5 / 2017-08-21 +================== + + * Fix issue with viewHome tracking. + +1.0.4 / 2017-08-17 +================== + + * Fix issue with viewHome tracking. + +1.0.3 / 2017-08-02 +================== + + * Replace lodash modules. + +1.0.2 / 2017-08-01 +================== + + * Move dependencies out of dev. + +1.0.1 / 2017-08-01 +================== + + * Add dependencies. + * Update Karma harnesses. + +1.0.0 / 2017-08-01 +================== + + * Initial release. diff --git a/integrations/criteo/README.md b/integrations/criteo/README.md new file mode 100644 index 000000000..9d749d31e --- /dev/null +++ b/integrations/criteo/README.md @@ -0,0 +1,8 @@ +# analytics.js-integration-criteo +[![CircleCI](https://ci.segment.com/gh/segment-integrations/analytics.js-integration-criteo.svg?style=svg&circle-token=e4cf681a9ecaca7541ce24b042ef669f234932bd)](https://ci.segment.com/gh/segment-integrations/analytics.js-integration-criteo) + +Criteo integration for Analytics.js. + +## License + +Released under the [MIT license](LICENSE). diff --git a/integrations/criteo/lib/index.js b/integrations/criteo/lib/index.js new file mode 100644 index 000000000..3b7f4fc86 --- /dev/null +++ b/integrations/criteo/lib/index.js @@ -0,0 +1,238 @@ +'use strict'; + +var objCase = require('obj-case'); +var extend = require('@ndhoule/extend'); +var values = require('@ndhoule/values'); +var pick = require('@ndhoule/pick'); +var each = require('@ndhoule/each'); +var md5 = require('md5'); +var isEmail = require('is-email'); +var useHttps = require('use-https'); +var is = require('is'); + +/** + * Module dependencies. + */ + +var integration = require('@segment/analytics.js-integration'); + +/** + * Expose Criteo integration. + */ + +var Criteo = module.exports = integration('Criteo') + .option('account', '') + .option('homeUrl', '') + .option('supportingUserData', {}) + .option('supportingPageData', {}) + .tag('http', '