diff options
author | Vincent Ambo <tazjin@google.com> | 2020-05-25T01·19+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-05-25T01·19+0100 |
commit | b99b368d17f2e806a61f7abb83c6d3a9e4bbdc38 (patch) | |
tree | 1f76047dd027421dcf79cdf4804fa5ff1bb08b2b /third_party/nix/src/nix/upgrade-nix.cc | |
parent | 8cf1322a6fd5ae282d8a09fdba634f27a1a88560 (diff) |
refactor(3p/nix/libutil): Replace hasPrefix/Suffix with Abseil r/845
Uses the equivalent absl::StartsWith and absl::EndsWith functions instead.
Diffstat (limited to 'third_party/nix/src/nix/upgrade-nix.cc')
-rw-r--r-- | third_party/nix/src/nix/upgrade-nix.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/third_party/nix/src/nix/upgrade-nix.cc b/third_party/nix/src/nix/upgrade-nix.cc index 08c411f4b4c5..7098e0eb904d 100644 --- a/third_party/nix/src/nix/upgrade-nix.cc +++ b/third_party/nix/src/nix/upgrade-nix.cc @@ -1,3 +1,4 @@ +#include <absl/strings/match.h> #include <glog/logging.h> #include "attr-path.hh" @@ -114,7 +115,7 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand { LOG(INFO) << "found Nix in '" << where << "'"; - if (hasPrefix(where, "/run/current-system")) { + if (absl::StartsWith(where, "/run/current-system")) { throw Error("Nix on NixOS must be upgraded via 'nixos-rebuild'"); } @@ -130,7 +131,8 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand { Path userEnv = canonPath(profileDir, true); - if (baseNameOf(where) != "bin" || !hasSuffix(userEnv, "user-environment")) { + if (baseNameOf(where) != "bin" || + !absl::EndsWith(userEnv, "user-environment")) { throw Error("directory '%s' does not appear to be part of a Nix profile", where); } |