Skip to content

Commit 87b0a45

Browse files
committed
Fsdk/Git: added functions to work with tags
1 parent aaa6a4d commit 87b0a45

File tree

1 file changed

+116
-0
lines changed

1 file changed

+116
-0
lines changed

Fsdk/Git.fs

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,3 +329,119 @@ module Git =
329329
else
330330
let lastCommitSingleOutput = lines.[0]
331331
sprintf "(%s/%s)" branch lastCommitSingleOutput
332+
333+
let GetTags() =
334+
let tags =
335+
Process
336+
.Execute(
337+
{
338+
Command = "git"
339+
Arguments = "tag"
340+
},
341+
Echo.All
342+
)
343+
.UnwrapDefault()
344+
345+
let tagsSplitted =
346+
tags.Split(
347+
[| "\r\n"; "\n" |],
348+
StringSplitOptions.RemoveEmptyEntries
349+
)
350+
351+
tagsSplitted
352+
353+
let DoesTagExist(tagName: string) =
354+
GetTags() |> Seq.contains tagName
355+
356+
let CreateTag(tagName: string) =
357+
Process
358+
.Execute(
359+
{
360+
Command = "git"
361+
Arguments = (sprintf "tag %s" tagName)
362+
},
363+
Echo.All
364+
)
365+
.UnwrapDefault()
366+
|> ignore<string>
367+
368+
let processResultRemote =
369+
Process.Execute(
370+
{
371+
Command = "git"
372+
Arguments = "push --tags"
373+
},
374+
Echo.All
375+
)
376+
377+
let _remoteResultRemote =
378+
match processResultRemote.Result with
379+
| ProcessResultState.Error(_exitCode, output) ->
380+
failwith(
381+
sprintf
382+
"pushing tags finished with an error: %s"
383+
output.StdErr
384+
)
385+
| _ -> ()
386+
387+
()
388+
389+
let CreateTagWithForce(tagName: string) =
390+
Process
391+
.Execute(
392+
{
393+
Command = "git"
394+
Arguments = sprintf "tag %s --force" tagName
395+
},
396+
Echo.All
397+
)
398+
.UnwrapDefault()
399+
|> ignore<string>
400+
401+
let processResultRemote =
402+
Process.Execute(
403+
{
404+
Command = "git"
405+
Arguments =
406+
sprintf "push origin \"refs/tags/%s\" --force" tagName
407+
},
408+
Echo.All
409+
)
410+
411+
match processResultRemote.Result with
412+
| ProcessResultState.Error(_exitCode, output) ->
413+
failwithf "pushing tag finished with an error: %s" output.StdErr
414+
| _ -> ()
415+
416+
let DeleteTag tagName =
417+
Process
418+
.Execute(
419+
{
420+
Command = "git"
421+
Arguments = (sprintf "tag --delete %s" tagName)
422+
},
423+
Echo.All
424+
)
425+
.UnwrapDefault()
426+
|> ignore<string>
427+
428+
let processResultRemote =
429+
Process.Execute(
430+
{
431+
Command = "git"
432+
Arguments = (sprintf "push --delete origin %s" tagName)
433+
},
434+
Echo.All
435+
)
436+
437+
let _processResultRemote =
438+
match processResultRemote.Result with
439+
| ProcessResultState.Error(_exitCode, output) ->
440+
failwith(
441+
sprintf
442+
"deleting remote tag finished with an error: %s"
443+
output.StdErr
444+
)
445+
| _ -> ()
446+
447+
()

0 commit comments

Comments
 (0)