Best practices for setting version number when commit is made using git -



Best practices for setting version number when commit is made using git -

i want automatically set version number programme in such way consistent git tags. how done? , suggested way of doing this?

example

the next highly sophisticated python script prints version number. how should automatically update version number each time commit something?

# application.py hardcoded_version_number = "0" print("v"+hardcoded_version_number)

after each commit version number should updated.

release 0.1 / initial commit:

hardcoded_version_number = "0.1" print("v"+hardcoded_version_number)

feature 1:

hardcoded_version_number = "0.1-1-gf5ffa14" # or print("v"+hardcoded_version_number)

release 0.2:

hardcoded_version_number = "0.2" print("v"+hardcoded_version_number)

etc...

another problem have gui element i'm using can't read version number external sources during runtime. alternative have hardcode it.

in terms of generating names these versions think you're on right track. git describe generates strings of form you're looking for:

the command finds recent tag reachable commit. if tag points commit, tag shown. otherwise, suffixes tag name number of additional commits on top of tagged object , abbreviated object name of recent commit.

if want access version string code you've got 2 options:

extract using git describe during build phase. in case you'll want write untracked temporary file, can read programme @ run time. i've used method, , works well.

use .gitattributes filter smudge , clean file. i've never used myself, way files in working re-create can automatically modified same files in repository.

why these necessary? git doesn't allow write commit's hash itself. commit hash computed based on number of things, including file content, commit message, timestamp, , parent hashes. time know hash is, commit references locked. modifying content or commit message include hash invalidates old hash.

see this question more discussion.

git version

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -