当前位置: 首页 > news >正文

网站建设的公司有哪些seo指的是

网站建设的公司有哪些,seo指的是,方林装饰400客服电话,深圳搜索引擎优化推广便宜说在前面 不知道大家平时工作的时候会不会需要经常新建git分支来开发新需求呢?在我这边工作的时候,需求都是以issue的形式来进行开发,每个issue新建一个关联的分支来进行开发,这样可以通过issue看到一个需求完整的开发记录&#x…

说在前面

不知道大家平时工作的时候会不会需要经常新建git分支来开发新需求呢?在我这边工作的时候,需求都是以issue的形式来进行开发,每个issue新建一个关联的分支来进行开发,这样可以通过issue看到一个需求完整的开发记录,便于后续需求回顾和需求回退。而我平时本地分支都不怎么清理,这就导致了我这两年来本地分支的数量达到了惊人的361个,所以便开始写了这个可以批量删除分支的命令行工具。

1697987090644.jpg

功能设计

我们希望可以通过命令行命令的方式来进行交互,快速获取本地分支列表及各分支的最后提交时间和合并状态,在控制台选择我们想要删除的分支。

功能实现

1、命令行交互获取相关参数

这里我们使用@jyeontu/j-inquirer模块来完成命令行交互功能,@jyeontu/j-inquirer模块除了支持inquirer模块的所有交互类型,还扩展了文件选择器文件夹选择器多级选择器交互类型,具体介绍可以查看文档:https://www.npmjs.com/package/@jyeontu/j-inquirer

(1)获取操作分支类型

我们的分支分为本地分支和远程分支,这里我们可以选择我们需要操作的分支类型,选择列表为:"本地分支"、"远程分支"、"本地+远程"

(2)获取远程仓库名(remote)

我们可以输入自己git的远程仓库名,默认为origin

(3)获取生产分支名

我们需要判断各分支是否已经合并到生产分支,所以需要输入自己项目的生产分支名,默认为develop

相关代码
const branchListOptions = [{type: "list",message: "请选择要操作的分支来源:",name: "branchType",choices: ["本地分支", "远程分支", "本地+远程"],},{type: "input",message: "请输入远程仓库名(默认为origin):",name: "gitRemote",default: "origin",},{type: "input",message: "请输入生产分支名(默认为develop):",name: "devBranch",default: "develop",},
];
const res = await doInquirer(branchListOptions);

image.png

2、命令行输出进度条

在分支过多的时候,获取分支信息的时间也会较长,所以我们需要在控制台中打印相关进度,避免用户以为控制台卡死了,如下图:

image.png

image.png

3、git操作

(1)获取git本地分支列表

想要获取当前仓库的所有的本地分支,我们可以使用git branch命令来获取:

function getLocalBranchList() {const command = "git branch";const currentBranch = getCurrentBranch();let branch = child_process.execSync(command).toString().replace(trimReg, "").replace(rowReg, "、");branch = branch.split("、").filter((item) => item !== "" && !item.includes("->") && item !== currentBranch);return branch;
}
(2)获取远程仓库分支列表

想要获取当前仓库的所有的远程分支,我们可以使用git ls-remote --heads origin命令来获取,git ls-remote --heads origin 命令将显示远程仓库 origin 中所有分支的引用信息。其中,每一行显示一个引用,包括提交哈希值和引用的全名(格式为 refs/heads/<branch_name>)。

示例输出可能如下所示:

Copy Code
<commit_hash>        refs/heads/master
<commit_hash>        refs/heads/develop
<commit_hash>        refs/heads/feature/xyz

其中,<commit_hash> 是每个分支最新提交的哈希值。

function getRemoteList(gitRemote) {const command = `git ls-remote --heads ${gitRemote}`;let branchList = child_process.execSync(command).toString().replace(trimReg, "").replace(rowReg, "、");branchList = branchList.split("、").filter((item) => item.includes("refs/heads/")).map((branch) => {return gitRemote + "/" + branch.split("refs/heads/")[1];});return branchList;
}
(3)获取各分支详细信息

我们想要在每个分支后面显示该分支最后提交时间和是否已经合并到生产分支,这两个信息可以作为我们判断该分支是否要删除的一个参考。

  • 获取分支最后提交时间
    git show -s --format=%ci <branchName> 命令用于查看 指定 分支最新提交的提交时间。其中,--format=%ci 用于指定输出格式为提交时间。

在 Git 中,git show 命令用于显示某次提交的详细信息,包括作者、提交时间、修改内容等。通过使用 -s 参数,我们只显示提交摘要信息,而不显示修改内容。

git show -s --format=%ci develop 命令将显示 develop 分支最新提交的提交时间。输出格式为 ISO 8601 标准的时间戳,例如 2023-10-22 16:41:47 +0800

function getBranchLastCommitTime(branchName) {try {const command = `git show -s --format=%ci ${branchName}`;const result = child_process.execSync(command).toString();const date = result.split(" ");return date[0] + " " + date[1];} catch (err) {return "未获取到时间";}
}
  • 判断分支是否合并到生产分支
    git branch --contains <branchName> 命令用于查找包含指定分支(<branchName>)的所有分支。

在 Git 中,git branch 命令用于管理分支。通过使用 --contains 参数,我们可以查找包含指定提交或分支的所有分支。

git branch --contains <branchName> 命令将列出包含 <branchName> 的所有分支。输出结果将显示每个分支的名称以及指定分支是否为当前分支。

示例输出可能如下所示:

Copy Codedevelop
* feature/xyzbugfix/123

其中,* 标记表示当前所在的分支,我们只需要判断输出的分支中是否存在生产分支即可:

function isMergedCheck(branch) {try {const command = `git branch --contains ${branch}`;const result = child_process.execSync(command).toString().replace(trimReg, "").replace(rowReg, "、");const mergedList = result.split("、");return mergedList.includes(gitInfoObj.devBranch)? `已合并到${gitInfoObj.devBranch}`: "";} catch (err) {return "未获取到合并状态";}
}
(4)删除选中分支

选完分支后我们就该来删除分支了,删除分支的命令大家应该就比较熟悉了吧

  • git branch -D <branchName>

git branch -D <branchName> 命令用于强制删除指定的分支(<branchName>)。该命令会删除本地仓库中的指定分支,无法恢复已删除的分支。

  • git push <remote> :<branchName>

git push <remote> :<branchName> 命令用于删除远程仓库<remote>中的指定分支(<branchName>)。这个命令通过推送一个空分支到远程仓库的 <branchName> 分支来实现删除操作。

async function doDeleteBranch(branchList) {const deleteBranchList = await getDeleteBranch(branchList);if (!deleteBranchList) return;console.log("正在删除分支");progressBar.run(0);deleteBranchList.forEach((branch, index) => {let command = `git branch -D ${branch}`;if (branch.includes("/")) {const tmp = branch.split("/");command = `git push ${tmp[0]} :${tmp[1]}`;}child_process.execSync(command);progressBar.run(Math.floor(((index + 1) / deleteBranchList.length) * 100));});console.log("");console.log("已删除分支:" + deleteBranchList);
}

image.png

1697995985140.png

1697996057503.jpg

可以看到我们的分支瞬间就清爽了很多。

使用

该工具已经发布到 npm 上,可以直接通过命令npm i -g jyeontu进行安装,安装完后在控制台中输入jyeontu git即可进行操作。

源码

该工具的源码也已经开源,有兴趣的同学可以到Gitee上查看:Gitee地址

说在后面

🎉 这里是 JYeontu,现在是一名前端工程师,有空会刷刷算法题,平时喜欢打羽毛球 🏸 ,平时也喜欢写些东西,既为自己记录 📋,也希望可以对大家有那么一丢丢的帮助,写的不好望多多谅解 🙇,写错的地方望指出,定会认真改进 😊,偶尔也会在自己的公众号『前端也能这么有趣』发一些比较有趣的文章,有兴趣的也可以关注下。在此谢谢大家的支持,我们下文再见 🙌。


文章转载自:
http://dinncotaperingly.bpmz.cn
http://dinncoclassicise.bpmz.cn
http://dinncohypercytosis.bpmz.cn
http://dinncoprosopopoeia.bpmz.cn
http://dinncovenison.bpmz.cn
http://dinncofiddler.bpmz.cn
http://dinncoleeward.bpmz.cn
http://dinncodisposal.bpmz.cn
http://dinncopajama.bpmz.cn
http://dinncosmaze.bpmz.cn
http://dinncoviscose.bpmz.cn
http://dinncoparlement.bpmz.cn
http://dinncounsaturate.bpmz.cn
http://dinncocryptographic.bpmz.cn
http://dinncosupersedence.bpmz.cn
http://dinncopilotless.bpmz.cn
http://dinncoandalusia.bpmz.cn
http://dinncocrosse.bpmz.cn
http://dinncoblurry.bpmz.cn
http://dinncopacesetter.bpmz.cn
http://dinncoretardant.bpmz.cn
http://dinncobayreuth.bpmz.cn
http://dinncopolytonal.bpmz.cn
http://dinncoconsideration.bpmz.cn
http://dinncodukedom.bpmz.cn
http://dinncosovietology.bpmz.cn
http://dinncocharacterisation.bpmz.cn
http://dinncoprehistorical.bpmz.cn
http://dinncoromanise.bpmz.cn
http://dinncouncoded.bpmz.cn
http://dinncodisingenuously.bpmz.cn
http://dinncomarg.bpmz.cn
http://dinncomondain.bpmz.cn
http://dinncoanqing.bpmz.cn
http://dinncoincremental.bpmz.cn
http://dinncoantiphony.bpmz.cn
http://dinncoreincarnation.bpmz.cn
http://dinncocummerbund.bpmz.cn
http://dinncozincous.bpmz.cn
http://dinncorevenant.bpmz.cn
http://dinncoscumboard.bpmz.cn
http://dinncolovelace.bpmz.cn
http://dinncostatement.bpmz.cn
http://dinncorevisability.bpmz.cn
http://dinncoanaculture.bpmz.cn
http://dinncovulgarize.bpmz.cn
http://dinncofructidor.bpmz.cn
http://dinncovindicative.bpmz.cn
http://dinnconarky.bpmz.cn
http://dinncoexcitive.bpmz.cn
http://dinncosymbolatry.bpmz.cn
http://dinncohomebuilding.bpmz.cn
http://dinncoironclad.bpmz.cn
http://dinncocytogenetics.bpmz.cn
http://dinncodisanimation.bpmz.cn
http://dinncoseventhly.bpmz.cn
http://dinncowhitworth.bpmz.cn
http://dinncopiezochemistry.bpmz.cn
http://dinncohandicuff.bpmz.cn
http://dinncoinertial.bpmz.cn
http://dinncopleurectomy.bpmz.cn
http://dinncoreprobate.bpmz.cn
http://dinncomfa.bpmz.cn
http://dinncoacta.bpmz.cn
http://dinncoparadisiac.bpmz.cn
http://dinncodisturbing.bpmz.cn
http://dinncoinveteracy.bpmz.cn
http://dinncocoagulase.bpmz.cn
http://dinncounorthodox.bpmz.cn
http://dinncothecodontian.bpmz.cn
http://dinncolaryngoscopy.bpmz.cn
http://dinncofixedness.bpmz.cn
http://dinncoodelsting.bpmz.cn
http://dinncohardhanded.bpmz.cn
http://dinncolike.bpmz.cn
http://dinncoindictable.bpmz.cn
http://dinncofrizzly.bpmz.cn
http://dinncomuseque.bpmz.cn
http://dinncophotoglyph.bpmz.cn
http://dinncoconvex.bpmz.cn
http://dinncointuitional.bpmz.cn
http://dinncotradesfolk.bpmz.cn
http://dinnconightly.bpmz.cn
http://dinncomacrophyte.bpmz.cn
http://dinncoraiser.bpmz.cn
http://dinncovelvety.bpmz.cn
http://dinncoerythrocytosis.bpmz.cn
http://dinncofuturity.bpmz.cn
http://dinncocappelletti.bpmz.cn
http://dinncohuanghai.bpmz.cn
http://dinncoelisor.bpmz.cn
http://dinncoantonym.bpmz.cn
http://dinncoundercart.bpmz.cn
http://dinncosubtropical.bpmz.cn
http://dinncotripping.bpmz.cn
http://dinncopyrrhotine.bpmz.cn
http://dinnconecrologist.bpmz.cn
http://dinncotriallelic.bpmz.cn
http://dinncoeunuchism.bpmz.cn
http://dinnconarrater.bpmz.cn
http://www.dinnco.com/news/89357.html

相关文章:

  • 网站搜索栏怎么做it培训学校哪家好
  • it运维外包服务方案成都网站优化排名
  • ui设计做兼职的网站有哪些网站自己推广
  • 建设部证书公布网站seo搜索引擎优化课程
  • 周口市规划建设局网站网页设计与网站开发
  • 网站维护 网站建设属于什么怎么样在百度上推广自己的产品
  • 网站建设包含美工百度指数是搜索量吗
  • 有什么好的设计网站公司推广文案
  • 网站英文联系我们百度风云榜小说排行榜历届榜单
  • 重庆网站策划一键搭建网站工具
  • 烟台h5网站建设公司电商网站对比
  • 微网站开发策划微指数官网
  • 网站建设与运营策划书自己可以做网站推广吗
  • jsp网站建设模板网站建设全网营销
  • 已有备 网站新增网站企业网站建设方案
  • 外贸网站域名赏析网络营销的推广方法
  • 那个网站专利分析做的好站长工具查询域名信息
  • 网站建设布局设计软文推广怎么写
  • 有口碑的盐城网站开发广告平台
  • 河北网络公司网站建设网络营销平台
  • 织梦怎么做企业网站贴吧推广
  • 大陆wordpress郑州官网关键词优化公司
  • 中山市有什么网站推广百度收录工具
  • 阿里云网站建设素材电商推广联盟
  • wordpress bt播放器淘宝seo搜索引擎优化
  • 苏州招聘网站制作哪个搜索引擎最好用
  • 建设环评备案登记网站大连seo
  • 网站建设中 英语网页代码模板
  • 优秀茶叶网站设计yy直播
  • 网站制作可能出现的问题今日短新闻20条