kamal icon indicating copy to clipboard operation
kamal copied to clipboard

Kamal::Git.version now uses git describe

Open hey-leon opened this issue 2 years ago • 2 comments

Why change Kamal::Git.version?

Currently container names can get very long with - service, role, destination, sha and even possible uncommited changes. This can make them hard to read or compare.

Looking for feedback before finalising this PR

The tests are not passing but I am wondering if there is interest in this change or maybe an alternative one that would simply shorten the sha - e.g. git rev-parse --short HEAD

Description

Previously Kamal::Git.version used rev-parse to retrieve the current commits full sha. While this works it currently creates a very long version name. This PR changes it to use git describe, which will use a tag if it exists, suffix with an abberviated commit sha if there are new commits, and lastly suffix it the same as before if their are uncommited changes. Some e.g.

  • No tags, no uncommited changes: '12er34d5'
  • No tags, uncommited-changes: '12er34d5_uncommited_23494aa9'
  • Tags, no new commits, no uncommited changes: '1.2.3'
  • Tags, new commits, no uncommited changes: '1.2.3-12er34d5'
  • Tags, new commits, uncommited changes: '1.2.3-12er34d5_uncommited_23494aa9'

Further reading: https://git-scm.com/docs/git-describe

hey-leon avatar Aug 03 '23 16:08 hey-leon

This has been revised to update the new Kamal::Git module

hey-leon avatar Oct 06 '23 05:10 hey-leon

need this to be merged, then we can ping the correct container's hostname

xiaohui-zhangxh avatar Oct 16 '23 07:10 xiaohui-zhangxh