ramasilveyra / gitpkg

Publish packages as git tags
MIT License
274 stars 28 forks source link

Idempotent mode #60

Closed appsforartists closed 2 years ago

appsforartists commented 2 years ago

Currently, gitpkg throws an error if the tag it wants to write already exists. Ideally, this would not error if the contents of the new tag and the old tag are the same.

Therefore, I propose an idempotent mode. Before pushing the tag, it would amend the commit time to 0 (1/1/1970). Then, you should be able to simply compare the SHA of the existing tag with the new one, and treat the command as a success if they match.

This would enable publish to be run indiscriminately across many packages, without worrying about which ones have fresh changes. It would also make it possible to easily detect which packages have changes since the last publication (since they would still throw the error.)

(I should investigate this a bit more, but wanted to write it down while it was in my head.)

appsforartists commented 2 years ago

I've just confirmed that commit SHAs can be made idempotent if you add these lines to the top of uploadPackage:

  process.env.GIT_AUTHOR_DATE = `1970-01-01T00:00:00.000Z`;
  process.env.GIT_COMMITTER_DATE = `1970-01-01T00:00:00.000Z`;

To-do: