-
-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement the new artifacts hashing algorithm #1280
base: master
Are you sure you want to change the base?
Conversation
4bf9b05
to
1526bbe
Compare
375945f
to
c0b40e3
Compare
c0b40e3
to
26571a7
Compare
private/lib/coordinates.bzl
Outdated
@@ -57,17 +57,30 @@ def unpack_coordinates(coords): | |||
def _is_version_number(part): | |||
return part[0].isdigit() | |||
|
|||
def _unpack_if_necssary(coords): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Fixed.
@@ -45,7 +45,7 @@ public void shouldRenderAggregatingJarsAsJarWithNullShasum() { | |||
Set.of(), | |||
new TreeMap<>()); | |||
|
|||
Map<String, Object> rendered = new V2LockFile(repos, Set.of(aggregator), Set.of()).render(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please name -1
as a constant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
import java.util.TreeSet; | ||
import java.util.stream.Collectors; | ||
|
||
public class ArtifactsHash { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: final, javadoc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Also added copyright notice.
for (DependencyInfo info : infos) { | ||
StringBuilder line = new StringBuilder(); | ||
line.append(info.getCoordinates().toString()) | ||
.append(" | ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: name this separator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
// utility class | ||
} | ||
|
||
public static int calculateArtifactsHash(Collection<DependencyInfo> infos) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this format/spec need to be versioned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so: we're working on the DependencyInfo
at this point, and we can reconstruct that from either lock file format.
} | ||
|
||
groupId = Objects.requireNonNull(parts[0]); | ||
artifactId = Objects.requireNonNull(parts[1]); | ||
|
||
boolean isGradle = | ||
coordinates.contains("@") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can non-gradle coordinates contain @
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theoretically, a non-gradle coordinate can contain an @
character, but the Maven folks recommend against it: https://maven.apache.org/guides/mini/guide-naming-conventions.html
I've never seen one in the wild, and I think it's reasonable to tell people to use the Gradle format if it's something they really need.
} | ||
|
||
groupId = Objects.requireNonNull(parts[0]); | ||
artifactId = Objects.requireNonNull(parts[1]); | ||
|
||
boolean isGradle = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document this constructor formally on what formats are accepted. It's getting a bit harder to understand this code, and AFAIUC, we are trying to use this to canonicalize the format, so some documentation will be useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I have added a little white-lie about how we handle a:b:c
, but I'll create a follow up PR to make that true.
artifacts = _get_artifacts(lock_file_contents) | ||
|
||
for artifact in artifacts: | ||
line = "%s | %s | " % (to_external_form(artifact["coordinates"]), artifact["sha256"] if artifact["sha256"] else "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably want to mention that the format should also be updated in tandem with ArtifactsHash.java.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Also added a very similar comment to ArtifactsHash.java
Also please update the PR description with more details on why this is happening. |
47b1557
to
2df9618
Compare
No description provided.