From f12504000dff44468e1b83385871b3882c66ecac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Thu, 31 Aug 2023 02:47:19 +0200 Subject: [PATCH] Git tag fix --- src/git.ts | 12 ++++++++++++ src/index.ts | 5 +++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/git.ts b/src/git.ts index d1312b5..4b47977 100644 --- a/src/git.ts +++ b/src/git.ts @@ -36,6 +36,18 @@ export class GitBranchRef extends GitRef {} export class GitTagRef extends GitRef {} +export const gitFetch = pipe( + SimpleGitService, + + Effect.flatMap(git => + Effect.tryPromise({ + try: () => git.fetch(), + catch: mapSimpleGitErrors, + }) + ), +) + + export class GitRefNullNameError {} export const getGitRefName = pipe( diff --git a/src/index.ts b/src/index.ts index 00f6ec1..829b0fb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,7 +2,7 @@ import { Console, Context, Effect, pipe } from "effect" import simpleGit from "simple-git" import { parseArgv } from "./argv" import { parseEnv } from "./env" -import { SimpleGitService, getGitRef } from "./git" +import { SimpleGitService, getGitRef, gitFetch } from "./git" import { DefaultMatcher, SemVerMatcher, generateDockerTagsFromGitRef } from "./matchers" import { writeDockerTagsFile } from "./tags" @@ -19,7 +19,8 @@ const context = Context.empty().pipe( ) const main = pipe( - getGitRef, + gitFetch, + Effect.flatMap(() => getGitRef), Effect.flatMap(ref => generateDockerTagsFromGitRef(ref, [ new SemVerMatcher,