相关文章推荐
豪情万千的眼镜  ·  智能指针reset()·  4 天前    · 
豪情万千的眼镜  ·  Resources·  1 月前    · 
豪情万千的眼镜  ·  python 调用打印机 ...·  9 月前    · 
豪情万千的眼镜  ·  [Answer]-How to ...·  10 月前    · 
豪情万千的眼镜  ·  Java ...·  11 月前    · 
豪情万千的眼镜  ·  MySQL 导出数据 | ·  11 月前    · 
不爱学习的火腿肠  ·  java ...·  14 分钟前    · 
旅行中的铁链  ·  错误信息:SSL ShakeHand ...·  36 分钟前    · 
憨厚的金鱼  ·  Scanpy数据结构:AnnData - 何帅 ·  36 分钟前    · 
To simply query using the git command via the OS:
[s,git_hash_string] = system( 'git rev-parse HEAD' )
Not sure how this might play with Matlab's git stuff... I haven't touched that, but use git separately to manage several of my Matlab libraries. I assume the underlying git management is the same regardless of whether you initialized the repo in Matlab or outside of it.
do you know why the length of my output changes depending on the argument to sprintf?:
>> disp(sprintf( '%s' ,git_hash_string))
530132b03bf6ba9c7b5902235ca6a40716384658
>> disp(sprintf( '%d' ,git_hash_string))
53514849515098485198102549897579955985357485050515399975497524855495451565254535610
thnks for the help btw :)
If you are wanting to get a build number then I find the following works well:
system( "git describe --tags --first-parent --abbrev=7 --long --dirty --always" )
This will return the most recent tag in the repo, followed by the commit hash. I then write this to a file and append with a timestamp. You can then read the value from the file to get a build ID for your toolbox or similar, which can be displayed with the output.
Build: 1.0-4-gb52160e 03-Mar-2023 12:58:39
Inspired by the following from Stack Overflow .

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
 
推荐文章