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,