Skip to content

Commit

Permalink
0.6.10: retroactive tagging; closes #101
Browse files Browse the repository at this point in the history
  • Loading branch information
disruptek committed Jan 4, 2020
1 parent 9c8f5d4 commit 1d9e3f9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
4 changes: 2 additions & 2 deletions nimph.nimble
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "0.6.9"
version = "0.6.10"
author = "disruptek"
description = "nim package handler from the future"
license = "MIT"
Expand All @@ -9,7 +9,7 @@ requires "bump >= 1.8.18"
requires "npeg >= 0.21.3"
requires "result"
requires "https://github.com/disruptek/cutelog >= 1.1.0"
requires "https://github.com/disruptek/gittyup >= 2.0.5"
requires "https://github.com/disruptek/gittyup 2.1"
requires "https://github.com/stefantalpalaru/nim-unittest2 >= 0.0.1"

# fixup a dependency: regex 0.10.0 doesn't build with 1.0.4 stdlib
Expand Down
2 changes: 1 addition & 1 deletion src/nimph.nim
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ proc tagger*(strict = false;
project: Project
setupLocalProject(project)

if project.fixTags(dry_run = dry_run):
if project.fixTags(dry_run = dry_run, force = force):
if dry_run:
warn "run without --dry-run to fix these"
else:
Expand Down
31 changes: 25 additions & 6 deletions src/nimph/doctor.nim
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type
kind*: StateKind
why*: string

proc fixTags*(project: var Project; dry_run = true): bool =
proc fixTags*(project: var Project; dry_run = true; force = false): bool =
block:
if project.dist != Git or not project.repoLockReady:
info "not looking for missing tags because the repository is unready"
Expand All @@ -50,6 +50,11 @@ proc fixTags*(project: var Project; dry_run = true): bool =
notice &"refusing to tag {project.name} because its version is bizarre"
break

# open the repo so we can keep it in memory for tagging purposes
repository := openRepository(project.gitDir):
error &"unable to open repo at `{project.repo}`: {code.dumpError}"
break

# match up tags to versions to commits; we should probably
# copy these structures and remove matches, for efficiency...
var tagsNeeded = 0
Expand All @@ -69,13 +74,27 @@ proc fixTags*(project: var Project; dry_run = true): bool =
result = true
tagsNeeded.inc
else:
thing := repository.lookupThing($commit.oid):
notice &"unable to lookup {commit}"
continue
# try to create a tag for this version and commit
let nextTag = project.tags.nextTagFor(version)
oid := commit.owner.tagCreateLightweight(nextTag, commit):
notice &"unable to create new tag for {version}"
break found
var
nextTag = project.tags.nextTagFor(version)
tagged = thing.tagCreate(nextTag, force = force)
# first, try using the committer's signature
if tagged.isErr:
notice &"unable to create signed tag for {version}"
# fallback to a lightweight (unsigned) tag
tagged = thing.tagCreateLightweight(nextTag, force = force)
if tagged.isErr:
notice &"unable to create new tag for {version}"
break found
let
oid = tagged.get
# if that worked, let them know we did something
info &"created new tag {version} for {oid}"
info &"created new tag {version} as tag-{oid}"
# the oid created for the tag must be freed
dealloc oid

# save our advice 'til the end
if tagsNeeded > 0:
Expand Down

0 comments on commit 1d9e3f9

Please sign in to comment.