about summary refs log tree commit diff
path: root/pkgs/tools/package-management
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2019-12-04 21:30:09 +0100
committerGitHub <noreply@github.com>2019-12-04 21:30:09 +0100
commit034910f06859f4c0ce5ee009e0984ebc684ca359 (patch)
tree8dcc91bfca2f80192fa1189d378e96036ea3bc3f /pkgs/tools/package-management
parent9c7cd63b3dd25639951d6cdd66bc98858186791b (diff)
parent499369a5d765b394686446ea7767b8a9e69f872e (diff)
downloadnixlib-034910f06859f4c0ce5ee009e0984ebc684ca359.tar
nixlib-034910f06859f4c0ce5ee009e0984ebc684ca359.tar.gz
nixlib-034910f06859f4c0ce5ee009e0984ebc684ca359.tar.bz2
nixlib-034910f06859f4c0ce5ee009e0984ebc684ca359.tar.lz
nixlib-034910f06859f4c0ce5ee009e0984ebc684ca359.tar.xz
nixlib-034910f06859f4c0ce5ee009e0984ebc684ca359.tar.zst
nixlib-034910f06859f4c0ce5ee009e0984ebc684ca359.zip
Merge pull request #74981 from oxalica/cargo-edit-upgrade
cargo-edit: 0.3.3 -> 0.4.1
Diffstat (limited to 'pkgs/tools/package-management')
-rw-r--r--pkgs/tools/package-management/cargo-edit/default.nix16
-rw-r--r--pkgs/tools/package-management/cargo-edit/no_upgrade_index_in_tests.patch123
2 files changed, 136 insertions, 3 deletions
diff --git a/pkgs/tools/package-management/cargo-edit/default.nix b/pkgs/tools/package-management/cargo-edit/default.nix
index 8ddb8eb231b3..1cdcffd2e7be 100644
--- a/pkgs/tools/package-management/cargo-edit/default.nix
+++ b/pkgs/tools/package-management/cargo-edit/default.nix
@@ -4,21 +4,31 @@
 
 rustPlatform.buildRustPackage rec {
   pname = "cargo-edit";
-  version = "0.3.3";
+  version = "0.4.1";
 
   src = fetchFromGitHub {
     owner = "killercup";
     repo = pname;
     rev = "v${version}";
-    sha256 = "05b64bm9441crw74xlywjg2y3psljk2kf9xsrixaqwbnnahi0mm5";
+    sha256 = "087l8qdwfnnklw6zyjwflxh7hyhh4r7wala36cc4lrj7lag2xm9n";
   };
 
-  cargoSha256 = "1hjjw3i35vqr6nxsv2m3izq4x8c2a6wvl5c2kjlpg6shy9j2mjaa";
+  cargoSha256 = "1ih1p9jdwr1ymq2p6ipz6rybi17f3qn65kn4bqkgzx36afvpnd5l";
 
   nativeBuildInputs = lib.optional (!stdenv.isDarwin) pkgconfig;
   buildInputs = lib.optional (!stdenv.isDarwin) openssl;
   propagatedBuildInputs = lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.Security;
 
+  patches = [
+    # https://github.com/killercup/cargo-edit/pull/362
+    ./no_upgrade_index_in_tests.patch
+  ];
+
+  # The default `/build` will fail the test (seems) due to permission problem.
+  preCheck = ''
+    export TMPDIR="/tmp"
+  '';
+
   meta = with lib; {
     description = "A utility for managing cargo dependencies from the command line";
     homepage = https://github.com/killercup/cargo-edit;
diff --git a/pkgs/tools/package-management/cargo-edit/no_upgrade_index_in_tests.patch b/pkgs/tools/package-management/cargo-edit/no_upgrade_index_in_tests.patch
new file mode 100644
index 000000000000..56b216e7baa7
--- /dev/null
+++ b/pkgs/tools/package-management/cargo-edit/no_upgrade_index_in_tests.patch
@@ -0,0 +1,123 @@
+diff --git a/src/bin/add/main.rs b/src/bin/add/main.rs
+index 41cde585..848612b3 100644
+--- a/src/bin/add/main.rs
++++ b/src/bin/add/main.rs
+@@ -87,7 +87,7 @@ fn handle_add(args: &Args) -> Result<()> {
+     let mut manifest = Manifest::open(manifest_path)?;
+     let deps = &args.parse_dependencies()?;
+ 
+-    if !args.offline {
++    if !args.offline && std::env::var("CARGO_IS_TEST").is_err() {
+         let url = registry_url(
+             &find(&manifest_path)?,
+             args.registry.as_ref().map(String::as_ref),
+diff --git a/src/bin/upgrade/main.rs b/src/bin/upgrade/main.rs
+index cf2414da..c066e6f4 100644
+--- a/src/bin/upgrade/main.rs
++++ b/src/bin/upgrade/main.rs
+@@ -409,7 +409,7 @@ fn process(args: Args) -> Result<()> {
+         ..
+     } = args;
+ 
+-    if !args.offline && !to_lockfile {
++    if !args.offline && !to_lockfile && std::env::var("CARGO_IS_TEST").is_err() {
+         let url = registry_url(&find(&manifest_path)?, None)?;
+         update_registry_index(&url)?;
+     }
+@@ -427,7 +427,7 @@ fn process(args: Args) -> Result<()> {
+ 
+         // Update indices for any alternative registries, unless
+         // we're offline.
+-        if !args.offline {
++        if !args.offline && std::env::var("CARGO_IS_TEST").is_err() {
+             for registry_url in existing_dependencies
+                 .0
+                 .values()
+diff --git a/tests/cargo-add.rs b/tests/cargo-add.rs
+index fbdbf4e2..612ffa78 100644
+--- a/tests/cargo-add.rs
++++ b/tests/cargo-add.rs
+@@ -1184,6 +1184,7 @@ fn add_prints_message() {
+         "--vers=0.6.0",
+         &format!("--manifest-path={}", manifest),
+     ])
++    .with_env(&[("CARGO_IS_TEST", "1")])
+     .succeeds()
+     .and()
+     .stdout()
+@@ -1204,6 +1205,7 @@ fn add_prints_message_with_section() {
+         "--vers=0.1.0",
+         &format!("--manifest-path={}", manifest),
+     ])
++    .with_env(&[("CARGO_IS_TEST", "1")])
+     .succeeds()
+     .and()
+     .stdout()
+@@ -1224,6 +1226,7 @@ fn add_prints_message_for_dev_deps() {
+         "0.8.0",
+         &format!("--manifest-path={}", manifest),
+     ])
++    .with_env(&[("CARGO_IS_TEST", "1")])
+     .succeeds()
+     .and()
+     .stdout()
+@@ -1244,6 +1247,7 @@ fn add_prints_message_for_build_deps() {
+         "0.1.0",
+         &format!("--manifest-path={}", manifest),
+     ])
++    .with_env(&[("CARGO_IS_TEST", "1")])
+     .succeeds()
+     .and()
+     .stdout()
+diff --git a/tests/cargo-upgrade.rs b/tests/cargo-upgrade.rs
+index b11a88dc..cf117940 100644
+--- a/tests/cargo-upgrade.rs
++++ b/tests/cargo-upgrade.rs
+@@ -385,6 +385,7 @@ fn upgrade_workspace() {
+ 
+ /// Detect if attempting to run against a workspace root and give a helpful warning.
+ #[test]
++#[cfg(feature = "test-external-apis")]
+ fn detect_workspace() {
+     let (_tmpdir, root_manifest, _workspace_manifests) = copy_workspace_test();
+ 
+@@ -414,6 +415,7 @@ fn invalid_manifest() {
+         "--manifest-path",
+         &manifest,
+     ])
++    .with_env(&[("CARGO_IS_TEST", "1")])
+     .fails_with(1)
+     .and()
+     .stderr()
+@@ -442,6 +444,7 @@ fn invalid_root_manifest() {
+         "--manifest-path",
+         &manifest,
+     ])
++    .with_env(&[("CARGO_IS_TEST", "1")])
+     .fails_with(1)
+     .and()
+     .stderr()
+@@ -457,6 +460,7 @@ fn unknown_flags() {
+         "foo",
+         "--flag",
+     ])
++    .with_env(&[("CARGO_IS_TEST", "1")])
+     .fails_with(1)
+     .and()
+     .stderr()
+@@ -473,6 +477,7 @@ For more information try --help ",
+ 
+ // Verify that an upgraded Cargo.toml matches what we expect.
+ #[test]
++#[cfg(feature = "test-external-apis")]
+ fn upgrade_to_lockfile() {
+     let (tmpdir, manifest) = clone_out_test("tests/fixtures/upgrade/Cargo.toml.lockfile_source");
+     fs::copy(
+@@ -489,6 +494,7 @@ fn upgrade_to_lockfile() {
+ }
+ 
+ #[test]
++#[cfg(feature = "test-external-apis")]
+ fn upgrade_workspace_to_lockfile() {
+     let (tmpdir, root_manifest, _workspace_manifests) = copy_workspace_test();
+ 
\ No newline at end of file