laarc/monki

语言: JavaScript

git: https://github.com/laarc/monki

README.md (中文)

的Monki

monki-small

Monki基本上是github的cp。使用monki在您的仓库中重复使用代码,或将其他人的仓库复制到您现有仓库的子文件夹中。

它不会导入任何项目的历史记录。可以把它想象成直接将项目文件复制到子文件夹中。 monki的优点是子文件夹可以很容易地更新,而其他替代品(如git子模块/子树/等)通常需要某种管理。

安装

git clone https://github.com/laarc/monki然后symlink monki / bin / monki进入你的PATH。例如。

git clone https://github.com/laarc/monki
cd monki/bin
ln -s "$(pwd)/monki" ~/bin/

用法

在项目的git repo中的任何地方运行

$ monki clone user/project dstdir
$ git add dstdir
$ git commit

将项目文件从https://github.com/user/project复制到./dstdir。

稍后,该项目可能会添加一些新功能或修复一些错误。要提取这些更改,请运行

$ monki dstdir/
$ git add dstdir
$ git commit -m 'monki dstdir/`

不要直接更改dstdir下的任何文件。每当你通过monki dstdir /进行更改时,它们都会被覆盖。

要更改文件,请打开dstdir / monki.l(monki在初始克隆期间创建)并描述您要进行的更改。这是一个例子。

深入

这个回购的“sudoarc”子文件夹是Monki用法的一个例子。它是通过运行项目目录中的monki clone laarc / lumen-sudoarc sudoarc创建的,该目录克隆了laarc / lumen-sudoarc。它使我能够在这个仓库中重复使用该项目的代码,而不会有任何麻烦。每当我更新项目时,我都会运行monki sudoarc /来引入更改。

如果你访问laarc / lumen-sudoarc,你会注意到“流明”子文件夹也被Monki管理。在您的所有存储库中重复使用代码非常容易,因为只需运行monki clone yourname / yourproject目录即可。

流明子文件夹最初是通过运行:

$ git clone https://github.com/laarc/lumen-sudoarc sudoarc
$ cd sudoarc
$ monki clone sctb/lumen lumen
$ git add lumen
$ git commit
$ git push

这创建了流明/ monki.l以及所有Lumen的文件。 monki.l文件告诉Monki如何处理它所在的子文件夹。

如果您只想要某人的回购副本,那么您将不需要编辑任何monki.l文件。 monki clone foo / bar dst命令会自动为您生成dst / monki.l文件。

如果您想对其他人的仓库进行任何更改,请检查sudoarc的lumen / monki.l文件以查看示例。它指示monki克隆Lumen,使用各种hacks(如多行原始字符串语法)修改它,完全重建Lumen三次,然后使用make test运行测试套件。

(这就是为什么项目被创建的原因:我需要一种方法来monkeypatch Lumen,我不想分叉并处理保持同步。)

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

monki

monki-small

Monki is essentially cp for github. Use monki to re-use code among your repos, or to copy someone else's repo into a subfolder of your existing repo.

It doesn't import any of the project's history. Think of it like copying the project files straight into the subfolder. The advantage of monki is that the subfolder can be updated very easily, whereas other alternatives (like git submodules / subtrees / etc) usually require some sort of management.

Installation

git clone https://github.com/laarc/monki then symlink monki/bin/monki into your PATH. E.g.

git clone https://github.com/laarc/monki
cd monki/bin
ln -s "$(pwd)/monki" ~/bin/

Usage

Anywhere within your project's git repo, run

$ monki clone user/project dstdir
$ git add dstdir
$ git commit

to copy the project files from https://github.com/user/project into ./dstdir.

Later on, the project may add some new features or fix some bugs. To pull in those changes, run

$ monki dstdir/
$ git add dstdir
$ git commit -m 'monki dstdir/`

Don't make direct changes to any of the files under dstdir. They'll be overwritten whenever you pull in changes via monki dstdir/.

To change the files, open dstdir/monki.l (which monki creates during the initial clone) and describe the changes you wish to make. Here's an example.

In-depth

The "sudoarc" subfolder of this repo is an example of Monki's usage. It was created by running monki clone laarc/lumen-sudoarc sudoarc from the project directory, which clones laarc/lumen-sudoarc. It enables me to reuse that project's code in this repo without any hassle at all. Whenever I update the project, I run monki sudoarc/ to pull in the changes.

If you visit laarc/lumen-sudoarc, you'll notice the "lumen" subfolder is also manged by Monki. It's very easy to re-use code across all of your repos, since it's just a matter of running monki clone yourname/yourproject dir.

The lumen subfolder was originally created by running:

$ git clone https://github.com/laarc/lumen-sudoarc sudoarc
$ cd sudoarc
$ monki clone sctb/lumen lumen
$ git add lumen
$ git commit
$ git push

This created lumen/monki.l along with all of Lumen's files. A monki.l file tells Monki what to do to the subfolder it resides in.

If you just want a copy of someone's repo, then you won't need to edit any monki.l files. The monki clone foo/bar dst command automatically generates a dst/monki.l file for you.

If you want to make any changes to someone else's repo, examine sudoarc's lumen/monki.l file to see an example. It instructs monki to clone Lumen, modify it with various hacks (like multiline raw string syntax), fully rebuild Lumen three times, then run the test suite using make test.

(That's basically why the project was created: I needed a way to monkeypatch Lumen, and I didn't want to fork it and deal with keeping it in sync.)