getsentry / craft

The universal Sentry release CLI 🚀
MIT License
133 stars 15 forks source link

Handle the situation when there no tags are present in the repository #464

Closed tonyo closed 1 year ago

tonyo commented 1 year ago

Environment

What version are you running? 1.2.2

Steps to Reproduce

Run craft prepare step on the repository that has no Git tags.

Expected Result

prepare runs successfully.

Actual Result

The following error happened:

Error:  fatal: No names found, cannot describe anything.

  at Object.action (/usr/local/bin/craft:549:10630)
  at uMe.exec (/usr/local/bin/craft:549:10942)
  at /usr/local/bin/craft:548:6689
  at new Promise (<anonymous>)
  at lA.handleTaskData (/usr/local/bin/craft:548:6578)
  at lA.<anonymous> (/usr/local/bin/craft:548:6204)
  at Generator.next (<anonymous>)
  at a (/usr/local/bin/craft:545:1507)
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Error: Process completed with exit code 1.

It looks like craft prepare fails here when trying to fetch the latest tag from the repository: https://github.com/getsentry/craft/blob/d0bfdaffe8b3753ad0ad68de9f63c76798bfb118/src/commands/prepare.ts#L500

...or more specifically, here: https://github.com/getsentry/craft/blob/d0bfdaffe8b3753ad0ad68de9f63c76798bfb118/src/utils/git.ts#L38

Suggestion

getLatestTag() should not fail if there are no existing tags on the repository. The default return value can be an empty string, for example.

tonyo commented 1 year ago

Happened today when releasing https://github.com/getsentry/sentry-maven-plugin

asottile-sentry commented 1 year ago

dupe #342