【问题标题】:Emacs projectile with multiple repos (git/svn etc.) in one project在一个项目中具有多个 repos(git/svn 等)的 Emacs 弹丸
【发布时间】:2014-04-22 05:32:44
【问题描述】:

我有一个 git repo,其目录结构如下所示:

root ---------- src
        |
        |
        |------ 3rd

root 是我的工作目录,3rd 由多个第三方 git 子模块组成。
projectile-find-file 仅在 src 中查找文件,它不适用于子模块。

【问题讨论】:

  • 看来你自己解决了这个问题,太棒了!但是,您可能需要考虑在下面发布answer,而不是在您的问题中包含解决方案。 (您甚至可以在 48 小时后接受。)
  • @itsjeyd 谢谢你的提醒
  • 不客气,感谢您跟进我的建议! :)

标签: git emacs emacs-projectile


【解决方案1】:

projectile-git-command 使用git ls-files 列出属于该项目的文件,
所以我用下面的代码解决了这个问题:

(setq projectile-git-command "git-ls-all-files")

git-ls-all-files 是一个 shell 脚本:

\#!/bin/zsh
files=`git ls-files -co --exclude-standard`
sb_files=`git --no-pager submodule --quiet foreach 'git ls-files --full-name -co --exclude-standard | sed s!^!$path/!'`
all_files=$files$sb_files

echo $all_files

【讨论】:

  • 或者,多合一命令:(setq projectile-git-command "cat
  • 太酷了!非常感谢你!并且两个 git ls-files 命令应该使用相同的标志-zco
【解决方案2】:

我刚刚遇到了一个类似的问题,我通过在我的 root 目录中添加一个空的 .projectile 文件来修复它,这告诉 projectile 该目录是真正的项目根目录,并在您搜索其子目录中的所有文件时想找点东西。

请参阅here 了解更多信息。

【讨论】:

  • 谢谢 - 这帮助我解决了与 OP 类似的问题。我需要一种方法来告诉 projectile 加载多个存储库(类似于 VSCode 中的“添加文件夹”),以便我可以 grep 并打开属于多个存储库的文件。
【解决方案3】:

除了Mike的解决方案,我在每个子模块中添加了一个.projectile文件,这个子模块在Emacs中会成为一个新的项目。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-11-23
    • 2020-04-06
    • 2011-01-10
    • 2010-11-20
    • 2023-03-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多