javascript - How could I show current GIT branch in my Vue 3 Web application
问题描述
I like to have a visual cue of the current GIT branch I am working on and have that set up in my IDE (I currently use VIM but I know VSCode also does this). I like/need it so much that I would really also like to see it in my development build when serving locally.
I currently do this manually with a label that I update by hand each time I create a new branch to work on. However, I often forget to do this and subsequently confuse myself.
I'm wondering whether it would be possible to pull this information from GIT and show it in my UI in the same way VSCode does?
Specifically I am using Vue 3 and Typescript but I guess that is not super relevant to the general problem.
Anyone have a feel of how you would do this?
解决方案
如果你使用 Webpack 作为打包器,有一个git-commit-info-webpack-plugin可以在每次构建时将一些 Git 信息(分支名称、最后提交日期/哈希/作者)写入 json 文件。
只需将 json 文件导入您的应用程序并使用它....
推荐阅读
- ruby-on-rails - 如何在 ActionCable `subscribed` 方法中查找模型
- sql-server - MS ACCESS 2013-2016 连续表单在通过 ADO 连接到 SQL SERVER 时添加任何超过第 3 条的记录时显示错误。这可以解决吗?
- multithreading - 包配置文件中的 find_dependency(Threads) 或 include(FindThreads)
- python - 在numpy ndarray的子类中覆盖.T(转置)
- sql - 具有主键索引时删除唯一索引
- java - 如何解析 YAML 文件
- html - 如何在不重定向的情况下使下载属性工作?
- sql-server - SQL 数据库项目通过 jenkins 构建和发布
- python - 在 IoT Analytics 中触发的 Lambda 函数将 POST 请求发送到外部 API
- node.js - nodejs ntlm 获取用户组