跟踪git中子文件夹的版本号 [英] tracking version numbers of subfolders in git

查看:68
本文介绍了跟踪git中子文件夹的版本号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的团队正在使用github管理充满cms主题的私人仓库.我们将它们全部放在同一个仓库中,并通过子文件夹,标签跟踪它们,并在分支和提交中添加主题名称作为前缀

My team is using github to manage a private repo full of cms themes. We have them all within the same repo and keep track of them with subfolders, labels and keeping our branchs and commits prefixed with the theme name

IE
提交消息:"[超级主题]升级的导航包含悬停效果"
分支 super_theme-upgrade-navigation-hover

现在,我们想在主题的设置页面中引入语义版本控制,因此,如果单击一下,您将获得版本号,但是我不确定实现此目的的最佳方法

Now we want to introduce semantic versioning into the theme's settings page so if you click about, you get the version number, but I'm not sure the best way to implement this

我们可以使用git标签和git describe检查提交次数,但这仅在每个文件夹都是其自己的存储库时才有效.我们希望将它们保持在一起,因为这会简化在github上的讨论,因为影响一个主题的问题通常会影响另一个主题.它们都是不同的,但是密切相关.

We could use git tags and git describe to check the number of commits but this only works if each folder is its own repo. We want to keep them together because it makes discussions on github easier since an issue affecting one theme often affects another. They're all different, but very closely related.

我考虑过要添加一个脚本供我们检查主题json文件中的当前版本并对其进行递增,但是我不确定这是否足够自动化.我真的想确保我们不会与团队中的每个人发生版本冲突.不确定子模块是否可以在这里工作,因为我们希望它们始终是最新的.

I thought about adding a script for us to check the current version of in the theme's json file and incrementing it, but I'm not sure if this is automatic enough. I really want to be sure that we don't run into version conflicts with everyone on the team. Not sure if submodules would work here since we want them always up to date.

我想要一种仅当在该文件夹上工作的分支合并到master时才更新子文件夹的版本号的方法.

I want a way to update the version number for a subfolder only when a branch working on that folder is merged into master.

陷入困境.我什至不确定那是否是一个明确的问题,所以请澄清一下.

Stumped. I'm not even sure if thats a clear question, so please ask for clarification.

推荐答案

以下是将子文件夹版本附加到git历史记录的一种方法:

Here's one approach to attaching a subfolder version to the git history:

git describe $(git log -n 1 --format=%H -- path/to/subfolder)

这允许使用顶级标签来跟踪主要/次要版本控制(例如,名为1.0的标签),而修订版可以跟踪特定于子文件夹的提交/哈希(例如1.0-25-gcdcb9a7e).根据您是否发布构建工件(例如Maven,PyPI),您可能需要进行调整以匹配版本命名方面的约束,或者将哈希转储到某些工件元数据中.在工件中的某个地方包含哈希值对于跟踪很有用.

This allows using a top-level tag to track major/minor versioning (e.g. tag named 1.0), with revision tracking the commit/hash specific to the subfolder (e.g. 1.0-25-gcdcb9a7e). Depending on whether you're publishing build artifacts (e.g. Maven, PyPI) you might need to tweak to match constraints on version naming, or dump the hash to some artifact metadata. Including the hash somewhere in the artifact can be super useful for traceability.

这篇关于跟踪git中子文件夹的版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆