gpt4 book ai didi

ruby - 是否有日志可以查看来自 bundler 的 git 命令?

转载 作者:太空宇宙 更新时间:2023-11-03 18:03:32 26 4
gpt4 key购买 nike

我正在使用 bundle install 从公共(public)和私有(private) git 存储库中安装一些 Ruby gem。

问题是在通过 git 安装了一个特定的 gem 之后,本地目录被该 gem 的源代码污染了。就好像 git 仓库已经完全改变了。

有没有办法记录 bundler 正在运行的所有 git 命令,并确保它将 gems 的 git repos 放入正确的路径?

  1. 向 Gemfile 添加一个新的 gem
  2. 运行 bundle 安装
  3. 检查 README.markdown,它现在有完全不同的文本:

    # activerecord-import [![Build Status](https://travis-ci.org/zdennis/activerecord-import.svg?branch=master)](https://travis-ci.org/zdennis/activerecord-import)

为了恢复我的存储库,我运行 git reflog 然后运行 ​​git reset --hard 以恢复正确的提交。看起来在 bundle install 期间,git 命令运行正在检查一个特定的分支,它覆盖了我的 git repo 中的所有文件。

最佳答案

我不知道这是否会帮助您解决您的实际问题,但您的问题的答案是您可以通过设置 GIT_TRACE 查看正在执行的所有 git 命令 环境变量。在 macOS、Linux 等上,看起来像 GIT_TRACE=1 bundle install。 Windows 上的方法会有所不同。

这是具有一个依赖项的全新 Gemfile 的输出:

$ cat Gemfile
# frozen_string_literal: true
source "https://rubygems.org"
gem 'rack', git: 'https://github.com/rack/rack'

$ GIT_TRACE=1 bundle install
Fetching https://github.com/rack/rack
12:43:02.753769 git.c:415 trace: built-in: git clone https://github.com/rack/rack /Users/jordanr/.rbenv/gems/2.6.0/cache/bundler/git/rack-02d63969ed912ff0486a199e1ea3aa78127fbb67 --bare --no-hardlinks --quiet
12:43:02.800426 run-command.c:637 trace: run_command: unset GIT_DIR; ssh git@github.com 'git-upload-pack '\''rack/rack'\'''
12:43:06.059759 run-command.c:637 trace: run_command: git index-pack --stdin --fix-thin '--keep=fetch-pack 23789 on jordanr.local' --check-self-contained-and-connected
12:43:06.067881 git.c:415 trace: built-in: git index-pack --stdin --fix-thin '--keep=fetch-pack 23789 on jordanr.local' --check-self-contained-and-connected
12:43:06.945711 run-command.c:637 trace: run_command: git rev-list --objects --stdin --not --all --quiet
12:43:06.951101 git.c:415 trace: built-in: git rev-list --objects --stdin --not --all --quiet
12:43:06.974513 git.c:415 trace: built-in: git rev-parse --verify master
12:43:06.991681 git.c:415 trace: built-in: git fetch --force --quiet --tags /Users/jordanr/.rbenv/gems/2.6.0/cache/bundler/git/rack-02d63969ed912ff0486a199e1ea3aa78127fbb67
12:43:06.993341 run-command.c:637 trace: run_command: unset GIT_PREFIX; 'git-upload-pack '\''/Users/jordanr/.rbenv/gems/2.6.0/cache/bundler/git/rack-02d63969ed912ff0486a199e1ea3aa78127fbb67'\'''
12:43:07.000949 git.c:415 trace: built-in: git upload-pack /Users/jordanr/.rbenv/gems/2.6.0/cache/bundler/git/rack-02d63969ed912ff0486a199e1ea3aa78127fbb67
12:43:07.012806 run-command.c:637 trace: run_command: git rev-list --objects --stdin --not --all --quiet
12:43:07.022792 run-command.c:637 trace: run_command: git rev-list --objects --stdin --not --all --quiet
12:43:07.027701 git.c:415 trace: built-in: git rev-list --objects --stdin --not --all --quiet
12:43:07.034718 run-command.c:1553 run_processes_parallel: preparing to run up to 1 tasks
12:43:07.034753 run-command.c:1585 run_processes_parallel: done
12:43:07.034796 run-command.c:637 trace: run_command: git gc --auto --quiet
12:43:07.039832 git.c:415 trace: built-in: git gc --auto --quiet
12:43:07.050538 git.c:415 trace: built-in: git reset --hard 23580211825877c7ed3be5dd4f2996e67aa40a4e
12:43:07.074736 git.c:415 trace: built-in: git version
12:43:07.085179 git.c:659 trace: exec: git-submodule deinit --all --force
12:43:07.086081 run-command.c:637 trace: run_command: git-submodule deinit --all --force
12:43:07.124885 git.c:659 trace: exec: git-sh-i18n--envsubst --variables 'usage: $dashless $USAGE'
12:43:07.125490 run-command.c:637 trace: run_command: git-sh-i18n--envsubst --variables 'usage: $dashless $USAGE'
12:43:07.138222 git.c:659 trace: exec: git-sh-i18n--envsubst 'usage: $dashless $USAGE'
12:43:07.138930 run-command.c:637 trace: run_command: git-sh-i18n--envsubst 'usage: $dashless $USAGE'
12:43:07.158914 git.c:415 trace: built-in: git rev-parse --git-dir
12:43:07.166961 git.c:415 trace: built-in: git rev-parse --git-path objects
12:43:07.173881 git.c:415 trace: built-in: git rev-parse -q --git-dir
12:43:07.187418 git.c:415 trace: built-in: git rev-parse --show-prefix
12:43:07.193585 git.c:415 trace: built-in: git rev-parse --show-toplevel
12:43:07.203435 git.c:415 trace: built-in: git submodule--helper deinit --force --all
Fetching gem metadata from https://rubygems.org/
Resolving dependencies...
Using bundler 2.0.1
Using rack 2.1.0 from https://github.com/rack/rack (at master@2358021)
Bundle complete! 1 Gemfile dependency, 2 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

关于ruby - 是否有日志可以查看来自 bundler 的 git 命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55732199/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com