ember-cli-deploy / ember-cli-deploy/ember-cli-deploy-revision-data

Git info is generated in the dist dir

未关闭
#52 21 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
JavaScript
星标
22
派生
57
PR 合并指标
30 天内没有已合并 PR

描述

The Git info is currently generated in [the dist dir](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/blob/master/index.js#L65) which causes problems if that dir is outside of the repo.

In our case we're deploying from a Docker container and mount the host's `tmp` dir as the `tmp` dir in the container. As that dir is a volume then and no regular folder any git operations performed in that dir won't work, leading to the error:

```
fatal: Not a git repository (or any parent up to mount point /usr/src/app/tmp)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

/usr/src/app/node_modules/ember-cli-deploy-revision-data/lib/scm-data-generators/git.js:16
var info = log.latest;
^

TypeError: Cannot read property 'latest' of null
at /usr/src/app/node_modules/ember-cli-deploy-revision-data/lib/scm-data-generators/git.js:16:23
at Git. (/usr/src/app/node_modules/simple-git/src/git.js:1276:13)
at Git. (/usr/src/app/node_modules/simple-git/src/git.js:1192:21)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:885:16)
at Socket. (internal/child_process.js:334:11)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at Pipe._handle.close [as _onclose] (net.js:501:12)
error Command failed with exit code 1.
```

The error in `git.js` being a consequence of the first 2 lines really:

```
fatal: Not a git repository (or any parent up to mount point /usr/src/app/tmp)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
```

`export GIT_DISCOVERY_ACROSS_FILESYSTEM = 1` actually does fix the problem for us but it seems suspicious that the git info is generated from the dist dir as opposed to the root of the repo or working directory that `ember deploy` is run from.

贡献指南

这个仓库没有索引到贡献指南

调研方向

从 index.js 第 65 行附近和 lib/scm-data-generators/git.js 第 16 行开始,追踪 Git 操作使用的是哪个目录。重现 Docker 挂载 tmp 的场景,或检查现有的 deployment 路径,然后验证 Git 信息是否是从预期的 repository 或 working directory 生成的,且不会出现文件系统边界错误。

由索引模型根据 Issue 内容生成。

评估

技术栈
git, javascript
领域
devops, release
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。