【问题标题】:How can I see modified files in a capistrano release?如何在 capistrano 版本中查看修改后的文件?
【发布时间】:2016-12-15 11:41:12
【问题描述】:

我想在发布新版本之前检查是否有人修改了我的文件(同事 -> 修补程序或黑客 -> hack)。 是否可以在 capistrano 版本中通过 git status 查看更改的文件?

$ ls -l
total 21692
lrwxrwxrwx 1 user www-data       55 Dec 14 14:31 current -> /path/to/my/releases/20161214132953
drwxr-xr-x 7 user www-data     4096 Dec 14 14:31 releases
drwxr-xr-x 7 user www-data     4096 Aug 18 14:05 repo
-rw-r--r-- 1 user www-data   121235 Dec 14 14:31 revisions.log
drwxr-xr-x 5 user www-data     4096 Dec  8  2014 shared
$ cd current
$ git status
fatal: Not a git repository (or any of the parent directories): .git
$ cd ../repo
$ git status
fatal: This operation must be run in a work tree

【问题讨论】:

    标签: git capistrano


    【解决方案1】:

    有办法做到,虽然不是很明显。

    首先,使用tail revisions.log 查找用于发布的 Git 提交 SHA。

    $ tail -n1 revisions.log
    Branch master (at 66ba18ca4f689a7e9fdc9a45ba3c952785620157) deployed as release 20161214132953 by mbrictson
    

    接下来,转到repo 目录并使用git archive 命令创建该提交时存在的存储库的原始快照。

    $ mkdir -p /tmp/pristine-release
    $ git archive 66ba18ca4 | tar -x -f - -C /tmp/pristine-release
    

    现在您可以使用diff 查看差异:

    $ diff -r /tmp/pristine-release /path/to/releases/20161214132953
    

    如果您想通过.gitignore 忽略文件,可以使用以下命令:

    rsync \
      -vanc\
      --no-links \
      --no-group \
      --no-owner \
      --no-perms \
      --no-times \
      --delete \
      --filter="dir-merge,- .gitignore" \
      /path/to/current/ \
      /tmp/pristine-release \
      | head -n -3 \
      | tail -n +2 \
      | grep -v 'skipping non-regular file'
    

    --filter="dir-merge,- .gitignore" 读取并使用 gitignore
    | head -n -3 删除 rsync 页脚
    | tail -n +2 删除 rsync 标头
    | grep -v 'skipping non-regular file' 从列表中删除跳过的文件

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-12
      • 1970-01-01
      • 2022-12-04
      • 2016-03-16
      • 2023-02-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多