Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

shs96c
Copy link
Collaborator

@shs96c shs96c commented Nov 7, 2024

No description provided.

@shs96c shs96c requested review from jin and cheister as code owners November 7, 2024 18:01
@shs96c shs96c force-pushed the new-artifacts-hash branch from 4bf9b05 to 1526bbe Compare November 13, 2024 15:45
@shs96c shs96c force-pushed the new-artifacts-hash branch 2 times, most recently from 375945f to c0b40e3 Compare November 25, 2024 13:48
@shs96c shs96c force-pushed the new-artifacts-hash branch from c0b40e3 to 26571a7 Compare December 2, 2024 15:34
@@ -57,17 +57,30 @@ def unpack_coordinates(coords):
def _is_version_number(part):
return part[0].isdigit()

def _unpack_if_necssary(coords):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo error

@@ -45,7 +45,7 @@ public void shouldRenderAggregatingJarsAsJarWithNullShasum() {
Set.of(),
new TreeMap<>());

Map<String, Object> rendered = new V2LockFile(repos, Set.of(aggregator), Set.of()).render();
Copy link
Collaborator

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.

import java.util.TreeSet;
import java.util.stream.Collectors;

public class ArtifactsHash {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: final, javadoc

for (DependencyInfo info : infos) {
StringBuilder line = new StringBuilder();
line.append(info.getCoordinates().toString())
.append(" | ")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: name this separator

// utility class
}

public static int calculateArtifactsHash(Collection<DependencyInfo> infos) {
Copy link
Collaborator

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?

}

groupId = Objects.requireNonNull(parts[0]);
artifactId = Objects.requireNonNull(parts[1]);

boolean isGradle =
coordinates.contains("@")
Copy link
Collaborator

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 @?

}

groupId = Objects.requireNonNull(parts[0]);
artifactId = Objects.requireNonNull(parts[1]);

boolean isGradle =
Copy link
Collaborator

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.

artifacts = _get_artifacts(lock_file_contents)

for artifact in artifacts:
line = "%s | %s | " % (to_external_form(artifact["coordinates"]), artifact["sha256"] if artifact["sha256"] else "")
Copy link
Collaborator

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.

@jin
Copy link
Collaborator

jin commented Dec 5, 2024

Also please update the PR description with more details on why this is happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants