win10管理凌乱桌面_用于管理凌乱的开源存储库的命令行技巧

win10管理凌乱桌面

Effective collaboration, especially in open source software development, starts with effective organization. To make sure that nothing gets missed, the general rule, “one issue, one pull request” is a nice rule of thumb.

有效的协作(特别是在开源软件开发中)始于有效的组织。 为确保不会遗漏任何东西,一般规则“一个问题,一个请求请求”是一个很好的经验法则。

Instead of opening an issue with a large scope like, “Fix all the broken links in the documentation,” open source projects will have more luck attracting contributors with several smaller and more manageable issues.

开源项目不会像“修复文档中所有断开的链接”这样的大问题,而是会吸引更多的贡献者,帮助他们解决一些更小,更易于管理的问题。

In the preceding example, you might scope broken links by section or by page. This allows more contributors to jump in and dedicate small windows of their time, rather than waiting for one person to take on a larger and more tedious contribution effort.

在前面的示例中,您可以按节或按页划分损坏的链接的范围。 这样一来,更多的贡献者就可以投入并奉献自己的时间,而不是等待一个人承担更大,更乏味的贡献。

Smaller scoped issues also help project maintainers see where work has been completed and where it hasn’t. This reduces the chances that some part of the issue is missed, assumed to be completed, and later leads to bugs or security vulnerabilities.

范围较小的问题还可以帮助项目维护人员查看工作已完成和未完成的地方。 这样可以减少错过问题的某些部分(假定已完成)的机会,并在以后导致错误或安全漏洞。

That’s all well and good. But what if you’ve already opened several massively-scoped issues, some PRs have already been submitted or merged, and you currently have no idea where the work started or stopped?

一切都很好。 但是,如果您已经打开了几个范围广泛的问题,已经提交或合并了一些PR,而您目前不知道工作在哪里开始或停止,该怎么办?

It’s going to take a little sorting out to get the state of your project back under control. Thankfully, there are a number of command line tools to help you scan, sort, and make sense of a messy repository. Here’s a small selection of ones I use.

需要进行一些整理以使项目状态重新得到控制。 值得庆幸的是,有许多命令行工具可帮助您扫描,排序和理解混乱的存储库。 这是我使用的一小部分。

vim交互式搜索和替换 (Interactive search-and-replace with vim)

You can open a file in Vim, then interactively search and replace with:

您可以在Vim中打开文件,然后以交互方式搜索并替换为:

:%s/\<word\>/newword/gc

The % indicates to look in all lines of the current file, s is for substitute, \<word\> matches the whole word, and the g for “global” is for every occurrence. The c at the end will let you view and confirm each change before it’s made. You can run it automatically, and much faster, without c, but you put yourself at risk of complicating things if you’ve made a pattern-matching error.

%表示在当前文件的所有行中查找, s表示替代, \<word\>匹配整个单词,而g表示“ global”,表示每次出现。 最后的c可以让您查看并确认每个更改,然后再进行更改。 您可以在没有c情况下自动且以更快的速度运行它,但是如果发生模式匹配错误,您就有使事情复杂化的风险。

The markdown-link-check node module has a great CLI buddy.

markdown-link-check节点模块具有出色的CLI伙伴

I use this so often I turned it into a Bash alias function. To do the same, add this to your .bashrc:

我经常使用它,因此将它变成Bash别名函数 。 为此,请将其添加到您的.bashrc

# Markdown link check in a folder, recursive
function mlc () {
    find $1 -name \*.md -exec markdown-link-check -p {} \;
}

Then run with mlc <filename>.

然后使用mlc <filename>运行。

列出具有或不具有git存储库的子目录以及find (List subdirectories with or without a git repository with find)

Print all subdirectories that are git repositories, or in other words, have a .git in them:

打印所有属于git存储库的子目录,或者换句话说,其中包含.git

find . -maxdepth 1 -type d -exec test -e '{}/.git' ';' -printf "is git repo: %p\n"

To print all subdirectories that are not git repositories, negate the test with !:

要打印不是git存储库的所有子目录,请使用!取消测试!

find . -maxdepth 1 -type d -exec test '!' -e '{}/.git' ';' -printf "not git repo: %p\n"

使用xargs从列表中拉出多个git存储库 (Pull multiple git repositories from a list with xargs)

I initially used this as part of automatically re-creating my laptop with Bash scripts, but it’s pretty handy when you’re working with cloud instances or Dockerfiles.

我最初将其用作使用Bash脚本自动重新创建笔记本电脑的一部分,但是当您使用云实例或Dockerfiles时,它非常方便。

Given a file, repos.txt with a repository’s SSH link on each line (and your SSH keys set up), run:

给定文件repos.txt并在每行上包含存储库的SSH链接(并设置SSH密钥),运行:

xargs -n1 git clone < repos.txt

If you want to pull and push many repositories, I previously wrote about how to use a Bash one-liner to manage your repositories.

如果您想拉动很多存储库,我之前曾写过关于如何使用Bash一线管理存储库的文章

用数字表的问题jot (List issues by number with jot)

I’m a co-author and maintainer for the OWASP Web Security Testing Guide repository where I recently took one large issue (yup, it was “Fix all the broken links in the documentation” - how’d you guess?) and broke it up into several smaller, more manageable issues. A whole thirty-seven smaller, more manageable issues.

我是OWASP Web安全测试指南存储库的合著者和维护者,最近在该存储库中遇到了一个大问题(是的,这是“修复文档中所有断开的链接” –您怎么猜?)并破坏了它分成几个较小的,更易于管理的问题。 总共37个较小的,更易于管理的问题。

I wanted to enumerate all the issues that the original one became, but the idea of typing out thirty-seven issue numbers (#275 through #312) seemed awfully tedious and time-consuming. So, in natural programmer fashion, I spent the same amount of time I would have used to type out all those numbers and crafted a way to automate it instead.

我想列举一下原来的所有问题,但是输入37个问题编号(#275至#312)的想法似乎很繁琐且耗时。 因此,以自然的程序员方式,我花费了与原本要键入所有这些数字相同的时间,并设计了一种自动化的方法。

The jot utility (apt install athena-jot) is a tiny tool that’s a big help when you want to print out some numbers. Just tell it how many you want, and where to start and stop.

jot实用程序( apt install athena-jot )是一个很小的工具,当您要打印一些数字时, apt install athena-jot您有很大帮助。 只需告诉它您想要多少,以及在哪里开始和停止。

# jot [ reps [ begin [ end ] ] ]
jot 37 275 312

This prints each number, inclusively, from 275 to 312 on a new line. To make these into issue number notations that GitHub and many other platforms automatically recognize and turn into links, you can pipe the output to awk.

这会在新行上打印每个数字(包括275至312)。 为了使这些成为GitHub和许多其他平台自动识别并转化为链接的问题编号符号,您可以将输出传递给awk

jot 37 275 312 | awk '{printf "#"$0", "}'

#275, #276, #277, #278, #279, #280, #281, #282, #283, #284, #285, #286, #287, #288, #289, #290, #291, #292, #293, #295, #296, #297, #298, #299, #300, #301, #302, #303, #304, #305, #306, #307, #308, #309, #310, #311, #312

You can also use jot to generate random or redundant data, mainly for development or testing purposes.

您还可以使用jot生成随机或冗余数据,主要用于开发或测试目的。

CLI驱动的开源组织 (CLI-powered open source organization)

A well-organized open source repository is a well-maintained open source project. Save this post for handy reference, and use your newfound CLI superpowers for good! 🚀

组织良好的开源资源库是维护良好的开源项目。 保存此帖子以方便参考,并永久使用您新发现的CLI超级功能! 🚀

翻译自: https://www.freecodecamp.org/news/command-line-tricks-for-managing-your-messy-open-source-repository/

win10管理凌乱桌面

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值