Skip to content

Commit

Permalink
Support version 1 of Package.resolved (#4)
Browse files Browse the repository at this point in the history
* Support version 1 of Package.resolved

* Set version to 0.2.0
  • Loading branch information
hbmartin authored Mar 21, 2024
1 parent ebcc5e5 commit 5c9cc81
Show file tree
Hide file tree
Showing 6 changed files with 184 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
danger-spm_version_updates (0.1.3)
danger-spm_version_updates (0.2.0)
danger-plugin-api (~> 1.0)
semantic (~> 1.6)
xcodeproj (~> 1.24)
Expand Down
2 changes: 1 addition & 1 deletion lib/spm_version_updates/gem_version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module SpmVersionUpdates
VERSION = "0.1.3"
VERSION = "0.2.0"
end
12 changes: 8 additions & 4 deletions lib/spm_version_updates/xcode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ def self.get_resolved_versions(xcodeproj_path)
raise(CouldNotFindResolvedFile) if resolved_paths.empty?

resolved_versions = resolved_paths.map { |resolved_path|
JSON.load_file!(resolved_path)["pins"]
.to_h { |pin|
[Git.trim_repo_url(pin["location"]), pin["state"]["version"] || pin["state"]["revision"]]
}
contents = JSON.load_file!(resolved_path)
pins = contents["pins"] || contents["object"]["pins"]
pins.to_h { |pin|
[
Git.trim_repo_url(pin["location"] || pin["repositoryURL"]),
pin["state"]["version"] || pin["state"]["revision"],
]
}
}
resolved_versions.reduce(:merge!)
end
Expand Down
15 changes: 15 additions & 0 deletions spec/spm_version_updates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,21 @@ module Danger
"5e5c3f78ff25e7678ed7d3b25d7c60eeeee47e25"
)
end

it "Reports new versions for version=1 Package.resolved" do
allow(Git).to receive(:version_tags)
.and_return [
Semantic::Version.new("3.1.3"),
]

@my_plugin.check_for_updates("#{File.dirname(__FILE__)}/support/fixtures/PackageV1.xcodeproj")

expect(@dangerfile.status_report[:warnings]).to eq(
[
"Newer version of gonzalezreal/NetworkImage: 3.1.3",
]
)
end
end
end
end
80 changes: 80 additions & 0 deletions spec/support/fixtures/PackageV1.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 54;
objects = {
/* Begin PBXGroup section */
F1465EF423AA94BF0055F7C3 = {
isa = PBXGroup;
children = (
F1465EFF23AA94BF0055F7C3 /* Demo */,
);
sourceTree = "<group>";
};
F1465EFF23AA94BF0055F7C3 /* Demo */ = {
isa = PBXGroup;
children = ();
path = Demo;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXProject section */
F1465EF523AA94BF0055F7C3 /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 1420;
LastUpgradeCheck = 1420;
TargetAttributes = {
F1465EFC23AA94BF0055F7C3 = {
CreatedOnToolsVersion = 11.2.1;
};
};
};
buildConfigurationList = F1465EF823AA94BF0055F7C3 /* Build configuration list for PBXProject "Demo" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
es,
"zh-Hans",
fr,
);
mainGroup = F1465EF423AA94BF0055F7C3;
packageReferences = (
11BBD37629C1571400F7A968 /* XCRemoteSwiftPackageReference "Nuke" */,
);
productRefGroup = F1465EFE23AA94BF0055F7C3 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = ();
};
/* End PBXProject section */

/* Begin XCConfigurationList section */
F1465EF823AA94BF0055F7C3 /* Build configuration list for PBXNativeTarget "Demo" */ = {
isa = XCConfigurationList;
buildConfigurations = ();
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
11BBD37629C1571400F7A968 /* XCRemoteSwiftPackageReference "Nuke" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/gonzalezreal/NetworkImage";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 3.1.0;
};
};
/* End XCRemoteSwiftPackageReference section */
};
rootObject = F1465EF523AA94BF0055F7C3 /* Project object */;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"object": {
"pins": [
{
"package": "AttributedText",
"repositoryURL": "https://github.com/gonzalezreal/AttributedText",
"state": {
"branch": null,
"revision": "c345033e22d5a1cd0e9fe0ec405cc809a8349586",
"version": "0.3.1"
}
},
{
"package": "combine-schedulers",
"repositoryURL": "https://github.com/pointfreeco/combine-schedulers",
"state": {
"branch": null,
"revision": "11973960af9c5426f22d337628cec4342c5e660d",
"version": "0.7.4"
}
},
{
"package": "Kingfisher",
"repositoryURL": "https://github.com/onevcat/Kingfisher",
"state": {
"branch": null,
"revision": "d06df9adf50ed8cde5786d935836a5f445f780ba",
"version": "6.3.1"
}
},
{
"package": "MarkdownUI",
"repositoryURL": "https://github.com/gonzalezreal/MarkdownUI",
"state": {
"branch": null,
"revision": "29d94710545952dd4c724cc2ca901848eef54ded",
"version": "0.5.2"
}
},
{
"package": "NetworkImage",
"repositoryURL": "https://github.com/gonzalezreal/NetworkImage",
"state": {
"branch": null,
"revision": "04167e81ed89a14b5da9b856ead306b969bb5abd",
"version": "3.1.2"
}
},
{
"package": "cmark",
"repositoryURL": "https://github.com/SwiftDocOrg/swift-cmark.git",
"state": {
"branch": null,
"revision": "9c8096a23f44794bde297452d87c455fc4f76d42",
"version": "0.29.0+20210102.9c8096a"
}
},
{
"package": "SwiftCommonMark",
"repositoryURL": "https://github.com/gonzalezreal/SwiftCommonMark",
"state": {
"branch": null,
"revision": "ed60da54305c244d0f77bc8d08495e04161e96a4",
"version": "0.1.2"
}
},
{
"package": "xctest-dynamic-overlay",
"repositoryURL": "https://github.com/pointfreeco/xctest-dynamic-overlay",
"state": {
"branch": null,
"revision": "38bc9242e4388b80bd23ddfdf3071428859e3260",
"version": "0.4.0"
}
}
]
},
"version": 1
}

0 comments on commit 5c9cc81

Please sign in to comment.