Quote arguments containing whitespace so the logged command line is copy-pasteable into a shell for reproduction.
| 25 | // Quote arguments containing whitespace so the logged command line is |
| 26 | // copy-pasteable into a shell for reproduction. |
| 27 | QString FormatCommand(const QString& program, const QStringList& args) |
| 28 | { |
| 29 | const auto quote = [](const QString& token) { |
| 30 | return token.contains(QChar::Space) ? '"' + token + '"' : token; |
| 31 | }; |
| 32 | |
| 33 | QString result = quote(program); |
| 34 | for (const auto& arg : args) |
| 35 | { |
| 36 | result += ' '; |
| 37 | result += quote(arg); |
| 38 | } |
| 39 | // Redact credentials from URLs: "://user:password@" -> "://****:****@" |
| 40 | static QRegularExpression credentialPattern("://[^/@]+:[^/@]+@"); |
| 41 | result.replace(credentialPattern, "://****:****@"); |
| 42 | |
| 43 | return result; |
| 44 | } |
| 45 | |
| 46 | // Canonicalize a package name per PEP 503: lowercase, and treat runs of |
| 47 | // '-', '_', '.' as a single '-'. Used to match resolved package names |
no test coverage detected