git - 使用 gnu make 提取 6 个字符的子字符串
问题描述
我使用以下方法提取了一个 git 哈希字符串:
git describe --always --abbrev=6
即我想获得 6 个字符。问题是如果 6 个字符的标签不是唯一的,git 似乎给了我 7 个字符。所以我想使用标准 make / bash 命令(如 sed)提取前 6 个字符。make 本身似乎不支持子字符串。
目前我的 make 脚本包含以下内容:
foo:=$(lastword $(subst M,,$(subst :, ,$(shell git describe --always --abbrev=6))))
这可能导致 foo=e94181c 但我喜欢它只是 e94181 以适应 24 位内存区域。
解决方案
我可能会这样做:
foo := $(shell git describe --always --abbrev=6 | cut -c 1-6)
推荐阅读
- python - 使用 Python 使我的逻辑回归测试准确度更接近我的训练准确度
- python - 如何多处理 Api 发布请求
- c# - 避免重复插入数据库
- swift - NSPopover 打开后没有收到第一次点击
- sqlalchemy - Sqlalchemy-Marshmallow - 嵌套字段不显示任何数据
- scheme - 如何计算列表中某个元素的出现次数并生成一个新列表?
- python - sys.getsizeof 如何在幕后工作?
- javascript - 如何在 JavaScript 中对美元数字范围进行排序
- python - TypeError:“spacy.tokens.token.Token”类型的参数不可迭代
- html - 如何修复导航栏不使用完整日历调整大小?