如何测试 composer.lock 是否是最新的?

How to test if composer.lock is up to date?(如何测试 composer.lock 是否是最新的?)
本文介绍了如何测试 composer.lock 是否是最新的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在开发过程中(团队中有多人)有时 composer install 返回:

During development (multiple people in the team) sometimes composer install returns:

警告:锁文件不是最新的 composer.json 中的最新更改.您可能会得到过时的依赖项.运行 update 以更新它们.

有没有办法快速检查(以毫秒为单位,无需进行任何更改)?

Is there a way to check for this very quickly (in milliseconds, without making any changes)?

我了解作曲家的工作原理.但是,当代码合并时,不一定会导致 composer.jsoncomposer.lock 文件发生合并冲突,并且运行 composer install 几乎没有任何更改并且该命令需要几分钟的时间.

I understand how composer works. However when code merges in it doesn't necessarily cause merge conflicts on the composer.json or composer.lock file and it's not fun to run composer install all the time when theres almost never any changes and that command takes several minutes.

如果我能够快速测试锁定失败是否不同步,我可以将其构建到 bash 环境中以通知每个命令.类似于人们喜欢将他们的 git status 内置到他们的 bash 提示符中.

If I'm able to quick test if the lock fail has fallen out of sync I can build it into the bash environment to notify every command. Similar to how people like their git status to be built into their bash prompt.

这在 CI 中更有意义,以确保它确实潜入稳定分支.

Further more this makes sense in CI to make sure it does sneak it's way into the stable branch.

推荐答案

对于作曲家 <1.3.0

For composer < 1.3.0

从@Domster扩展,纯bash中的解决方案:

Extending from @Domster, the solution in pure bash:

COMPOSER_IN_SYNC=$(expr "`cat composer.lock | grep '"hash":' | cut -d'"' -f4`" = "`md5sum composer.json | cut -d ' ' -f 1`")

$COMPOSER_IN_SYNC 将分别为 01.

这篇关于如何测试 composer.lock 是否是最新的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)