Skip to content

Commit 408c2fa

Browse files
committed
nix hash: Don't print 'nix hash' deprecation message
Fixes NixOS#11997.
1 parent 33b645c commit 408c2fa

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/nix/hash.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,11 @@ struct CmdToBase : Command
163163
HashFormat hashFormat;
164164
std::optional<HashAlgorithm> hashAlgo;
165165
std::vector<std::string> args;
166+
bool legacyCli;
166167

167-
CmdToBase(HashFormat hashFormat) : hashFormat(hashFormat)
168+
CmdToBase(HashFormat hashFormat, bool legacyCli = false)
169+
: hashFormat(hashFormat)
170+
, legacyCli(legacyCli)
168171
{
169172
addFlag(flag::hashAlgoOpt("type", &hashAlgo));
170173
expectArgs("strings", &args);
@@ -181,7 +184,8 @@ struct CmdToBase : Command
181184

182185
void run() override
183186
{
184-
warn("The old format conversion sub commands of `nix hash` were deprecated in favor of `nix hash convert`.");
187+
if (!legacyCli)
188+
warn("The old format conversion subcommands of `nix hash` were deprecated in favor of `nix hash convert`.");
185189
for (const auto & s : args)
186190
logger->cout(Hash::parseAny(s, hashAlgo).to_string(hashFormat, hashFormat == HashFormat::SRI));
187191
}
@@ -328,7 +332,7 @@ static int compatNixHash(int argc, char * * argv)
328332
}
329333

330334
else {
331-
CmdToBase cmd(hashFormat);
335+
CmdToBase cmd(hashFormat, true);
332336
cmd.args = ss;
333337
if (hashAlgo.has_value()) cmd.hashAlgo = hashAlgo;
334338
cmd.run();

0 commit comments

Comments
 (0)