Skip to content

Commit 75176c7

Browse files
committed
Review of package-alt
1 parent b4ea7a4 commit 75176c7

File tree

9 files changed

+254
-11
lines changed

9 files changed

+254
-11
lines changed
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
TODO
2+
====
3+
- in many instances we've wanted to do some amount of tranformation when converting from serialized
4+
stuff into our data structures. I've been thinking for a while that we may want to just have a
5+
separate parsing module that contains only the parsing data structures and
6+
serialization/deserialization code. We've been avoiding this for a while and I think it's
7+
causing us headaches
8+
9+
-
10+
11+
Needs review
12+
============
13+
- [X] dependency/dependency_set.rs
14+
- [X] dependency/mod.rs
15+
- [X] dependency/local.rs
16+
- [X] dependency/git.rs - will rereview with cleanup PR
17+
18+
- [ ] dependency/external.rs
19+
- [ ] mocks/mock-resolver.rs
20+
- [ ] jsonrpc/types.rs
21+
- [ ] jsonrpc/client.rs
22+
- [ ] jsonrpc/mod.rs
23+
- [ ] tests/jsonrpc_tests.rs
24+
25+
26+
- [ ] errors/manifest_error.rs
27+
- [ ] errors/git_error.rs
28+
- [ ] errors/files.rs
29+
- [ ] errors/mod.rs
30+
- [ ] errors/located.rs
31+
- [ ] errors/lockfile_error.rs
32+
- [ ] errors/resolver_error.rs
33+
- [ ] lib.rs
34+
35+
- [ ] main.rs
36+
- [ ] cli/build.rs
37+
- [ ] cli/mod.rs
38+
- [ ] cli/parse.rs
39+
40+
- [ ] package/mod.rs
41+
- [ ] flavor/vanilla.rs
42+
- [ ] flavor/mod.rs
43+
44+
- [ ] package/lockfile.rs
45+
- [ ] package/manifest.rs
46+
47+
- [ ] tests/test_runner.rs
48+
- [ ] tests/data/flavor_sui/Move@parsed.snap
49+
- [ ] tests/data/flavor_sui/Move.parsed
50+
- [ ] tests/data/flavor_sui/Move.toml
51+
- [ ] tests/data/edition_unknown/Move@parsed.snap
52+
- [ ] tests/data/edition_unknown/Move.parsed
53+
- [ ] tests/data/edition_unknown/Move.toml
54+
- [ ] tests/data/edition_2024_alpha/Move@parsed.snap
55+
- [ ] tests/data/edition_2024_alpha/Move.parsed
56+
- [ ] tests/data/edition_2024_alpha/Move.toml
57+
- [ ] tests/data/external_returns_external/Move.pinned
58+
- [ ] tests/data/external_returns_external/Move@pinned.snap
59+
- [ ] tests/data/external_returns_external/Move.toml
60+
- [ ] tests/data/too_many_entries_renaming_instantiation/Move@parsed.snap
61+
- [ ] tests/data/too_many_entries_renaming_instantiation/Move.parsed
62+
- [ ] tests/data/too_many_entries_renaming_instantiation/Move.toml
63+
- [ ] tests/data/invalid_lockfile_parsing/Move.snap
64+
- [ ] tests/data/no_path_set_for_dependency/Move@parsed.snap
65+
- [ ] tests/data/no_path_set_for_dependency/Move.parsed
66+
- [ ] tests/data/no_path_set_for_dependency/Move.toml
67+
- [ ] tests/data/flavor_unknown/Move@parsed.snap
68+
- [ ] tests/data/flavor_unknown/Move.parsed
69+
- [ ] tests/data/flavor_unknown/Move.toml
70+
- [ ] tests/data/invalid_identifier_package_name/Move@parsed.snap
71+
- [ ] tests/data/invalid_identifier_package_name/Move.parsed
72+
- [ ] tests/data/invalid_identifier_package_name/Move.toml
73+
- [ ] tests/data/missing_required_package_segment/Move@parsed.snap
74+
- [ ] tests/data/missing_required_package_segment/Move.parsed
75+
- [ ] tests/data/missing_required_package_segment/Move.toml
76+
- [ ] tests/data/missing_minimal_required_field_name/Move@parsed.snap
77+
- [ ] tests/data/missing_minimal_required_field_name/Move.parsed
78+
- [ ] tests/data/missing_minimal_required_field_name/Move.toml
79+
- [ ] tests/data/basic_implicit_deps/Move@parsed.snap
80+
- [ ] tests/data/basic_implicit_deps/Move.parsed
81+
- [ ] tests/data/basic_implicit_deps/Move.toml
82+
- [ ] tests/data/invalid_authors/Move@parsed.snap
83+
- [ ] tests/data/invalid_authors/Move.parsed
84+
- [ ] tests/data/invalid_authors/Move.toml
85+
- [ ] tests/data/lockfile_parsing_valid/Move.toml
86+
- [ ] tests/data/lockfile_parsing_valid/Move@locked.snap
87+
- [ ] tests/data/lockfile_parsing_valid/Move.lock
88+
- [ ] tests/data/lockfile_parsing_valid/Move.locked
89+
- [ ] tests/data/edition_unknown_suffix/Move@parsed.snap
90+
- [ ] tests/data/edition_unknown_suffix/Move.parsed
91+
- [ ] tests/data/edition_unknown_suffix/Move.toml
92+
- [ ] tests/data/flavor_global_storage/Move@parsed.snap
93+
- [ ] tests/data/flavor_global_storage/Move.parsed
94+
- [ ] tests/data/flavor_global_storage/Move.toml
95+
- [ ] tests/data/missing_required_envs_segment/Move.snap
96+
- [ ] tests/data/missing_required_envs_segment/Move.toml
97+
- [ ] tests/data/external_multiple_resolvers/Move.pinned
98+
- [ ] tests/data/external_multiple_resolvers/Move@pinned.snap
99+
- [ ] tests/data/external_multiple_resolvers/Move.toml
100+
- [ ] tests/data/non_identifier_address_name_in_subst/Move@parsed.snap
101+
- [ ] tests/data/non_identifier_address_name_in_subst/Move.parsed
102+
- [ ] tests/data/non_identifier_address_name_in_subst/Move.toml
103+
- [ ] tests/data/basic/Move@parsed.snap
104+
- [ ] tests/data/basic/Move.parsed
105+
- [ ] tests/data/basic/Move.toml
106+
- [ ] tests/data/external_missing_keys/Move.pinned
107+
- [ ] tests/data/external_missing_keys/Move@pinned.snap
108+
- [ ] tests/data/external_missing_keys/Move.toml
109+
- [ ] tests/data/package_name_empty/Move@parsed.snap
110+
- [ ] tests/data/package_name_empty/Move.parsed
111+
- [ ] tests/data/package_name_empty/Move.toml
112+
- [ ] tests/data/external_empty_output/Move.pinned
113+
- [ ] tests/data/external_empty_output/Move@pinned.snap
114+
- [ ] tests/data/external_empty_output/Move.toml
115+
- [ ] tests/data/edition_legacy/Move@parsed.snap
116+
- [ ] tests/data/edition_legacy/Move.parsed
117+
- [ ] tests/data/edition_legacy/Move.toml
118+
- [ ] tests/data/invalid_environment2/Move@parsed.snap
119+
- [ ] tests/data/invalid_environment2/Move.parsed
120+
- [ ] tests/data/invalid_environment2/Move.toml
121+
- [ ] tests/data/external_basic/Move@pinned.snap
122+
- [ ] tests/data/external_basic/Move.toml
123+
- [ ] tests/data/unknown_toplevel_field/Move@parsed.snap
124+
- [ ] tests/data/unknown_toplevel_field/Move.parsed
125+
- [ ] tests/data/unknown_toplevel_field/Move.toml
126+
- [ ] tests/data/edition_2024_beta/Move@parsed.snap
127+
- [ ] tests/data/edition_2024_beta/Move.parsed
128+
- [ ] tests/data/edition_2024_beta/Move.toml
129+
- [ ] tests/data/non_string_package_name/Move@parsed.snap
130+
- [ ] tests/data/non_string_package_name/Move.parsed
131+
- [ ] tests/data/non_string_package_name/Move.toml
132+
- [ ] tests/data/external_errorcode/Move.pinned
133+
- [ ] tests/data/external_errorcode/Move@pinned.snap
134+
- [ ] tests/data/external_errorcode/Move.toml
135+
- [ ] tests/data/invalid_environment/Move@parsed.snap
136+
- [ ] tests/data/invalid_environment/Move.parsed
137+
- [ ] tests/data/invalid_environment/Move.toml
138+
- [ ] tests/data/external_non_json/Move@pinned.snap
139+
- [ ] tests/data/external_non_json/Move.toml
140+
- [ ] tests/data/external_bad_schema/Move.pinned
141+
- [ ] tests/data/external_bad_schema/Move@pinned.snap
142+
- [ ] tests/data/external_bad_schema/Move.toml
143+
- [ ] tests/data/basic_with_bar/Move@parsed.snap
144+
- [ ] tests/data/basic_with_bar/Move.parsed
145+
- [ ] tests/data/basic_with_bar/Move.toml
146+
- [ ] tests/data/basic_with_bar/bar/Move@parsed.snap
147+
- [ ] tests/data/basic_with_bar/bar/Move.parsed
148+
- [ ] tests/data/basic_with_bar/bar/Move.toml
149+
- [ ] tests/data/edition_2024/Move@parsed.snap
150+
- [ ] tests/data/edition_2024/Move.parsed
151+
- [ ] tests/data/edition_2024/Move.toml
152+
- [ ] tests/data/basic_missing_git_dep/Move@parsed.snap
153+
- [ ] tests/data/basic_missing_git_dep/Move.parsed
154+
- [ ] tests/data/basic_missing_git_dep/Move.toml
155+
- [ ] tests/data/non_string_local_dep_path/Move@parsed.snap
156+
- [ ] tests/data/non_string_local_dep_path/Move.parsed
157+
- [ ] tests/data/non_string_local_dep_path/Move.toml
158+
- [ ] tests/data/integer_subst_in_dependency/Move@parsed.snap
159+
- [ ] tests/data/integer_subst_in_dependency/Move.parsed
160+
- [ ] tests/data/integer_subst_in_dependency/Move.toml
161+
- [ ] tests/data/basic_move_project/config
162+
- [ ] tests/data/basic_move_project/pkg_a/Move.toml
163+
- [ ] tests/data/basic_move_project/pkg_b/Move.toml
164+
- [ ] tests/data/invalid_hex_address_in_subst/Move@parsed.snap
165+
- [ ] tests/data/invalid_hex_address_in_subst/Move.parsed
166+
- [ ] tests/data/invalid_hex_address_in_subst/Move.toml
167+
- [ ] tests/data/basic_no_dep_override_git/Move@parsed.snap
168+
- [ ] tests/data/basic_no_dep_override_git/Move.parsed
169+
- [ ] tests/data/basic_no_dep_override_git/Move.toml
170+
- [ ] tests/data/duplicate_top_level_field/Move@parsed.snap
171+
- [ ] tests/data/duplicate_top_level_field/Move.parsed
172+
- [ ] tests/data/duplicate_top_level_field/Move.toml
173+
- [ ] tests/data/invalid_environment1/Move@parsed.snap
174+
- [ ] tests/data/invalid_environment1/Move.parsed
175+
- [ ] tests/data/invalid_environment1/Move.toml
176+
- [ ] tests/data/invalid_author/Move@parsed.snap
177+
- [ ] tests/data/invalid_author/Move.parsed
178+
- [ ] tests/data/invalid_author/Move.toml
179+
- [ ] tests/data/basic_external_resolver/Move@parsed.snap
180+
- [ ] tests/data/basic_external_resolver/Move.parsed
181+
- [ ] tests/data/basic_external_resolver/Move.toml

external-crates/move/crates/move-package-alt/src/dependency/dependency_set.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ use serde::{Deserialize, Serialize};
1414

1515
use crate::package::{EnvironmentName, PackageName};
1616

17+
// TODO (potential refactor): using [Option] here and representing the default environment as
18+
// [None] has led to some confusion, it might be better to make a specific enumeration, so that
19+
// [DependencySet] becomes closer to a vanilla map. In fact, in the dependency graph we'll have
20+
// `Option<EnvironmentName>, PackageName` edges - this might be a good type to encapsulate; then
21+
// DependencySet just becomes a map from edges to T. A little curry can go a long way
22+
1723
/// A set of default dependencies and dep replacements. Within each environment, package names are
1824
/// unique.
1925
///
@@ -77,6 +83,7 @@ impl<T> DependencySet<T> {
7783

7884
/// Convenience method to return either [default_deps] or [deps_for_env] depending on [env]; an
7985
/// [env] of [None] indicates a request for the default dependencies.
86+
/// TODO rename to deps
8087
pub fn deps_for(&self, env: Option<&EnvironmentName>) -> BTreeMap<PackageName, &T> {
8188
match env {
8289
Some(env) => self.deps_for_env(env),
@@ -127,6 +134,7 @@ impl<T> DependencySet<T> {
127134

128135
/// A copy of [self] expanded with an entry (package name, env, dep) for all
129136
/// packages in [self] and environments in [envs].
137+
/// TODO: rename to expand or extend
130138
pub fn explode(&mut self, envs: impl IntoIterator<Item = EnvironmentName>)
131139
where
132140
T: Clone,
@@ -263,6 +271,7 @@ impl<T> FromIterator<(Option<EnvironmentName>, PackageName, T)> for DependencySe
263271
}
264272
}
265273

274+
// TODO: maybe this can be derived with our fancy derive macros?
266275
// Note: can't be derived because that adds a spurious T: Default bound
267276
impl<T> Default for DependencySet<T> {
268277
/// The empty dependency set

external-crates/move/crates/move-package-alt/src/dependency/external.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ struct RField {
6060
}
6161

6262
/// Requests from the package mananger to the external resolver
63+
// TODO: fix typo above
6364
#[derive(Serialize, Debug)]
6465
struct ResolveRequest<F: MoveFlavor> {
6566
#[serde(default)]
@@ -135,6 +136,8 @@ impl ExternalDependency {
135136
}
136137
}
137138

139+
// TODO: CLEANUP
140+
// Explain this conversion
138141
impl TryFrom<RField> for ExternalDependency {
139142
type Error = PackageError;
140143

external-crates/move/crates/move-package-alt/src/dependency/git.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//!
77
//! Git dependencies are cached in `~/.move`, which has the following structure:
88
//!
9+
//! TODO: this doesn't match the implementation below:
910
//! ```ignore
1011
//! .move/
1112
//! git/
@@ -34,8 +35,17 @@ use crate::errors::{GitError, GitErrorKind, Located, PackageError, PackageResult
3435

3536
use super::{DependencySet, Pinned, Unpinned};
3637

38+
// TODO: (potential refactor): it might be good to separate out a separate module that is just git
39+
// stuff and another that uses that git stuff to implement the dependency operations (like
40+
// the jsonrpc / dependency::external split).
41+
42+
// TODO: curious about the benefit of using String instead of wrapping it. The advantage of
43+
// wrapping it is that we have invariants (with the type alias, nothing prevents us from
44+
// writing `let x : Sha = ""` (whereas `let x = Sha::new("")` can fail)
3745
type Sha = String;
3846

47+
/// TODO keep same style around all types
48+
///
3949
/// A git dependency that is unpinned. The `rev` field can be either empty, a branch, or a sha. To
4050
/// resolve this into a [`PinnedGitDependency`], call `pin_one` function.
4151
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
@@ -60,7 +70,6 @@ pub struct PinnedGitDependency {
6070
repo: String,
6171

6272
/// The exact sha for the revision
63-
// rev: Sha,
6473
#[serde(deserialize_with = "deserialize_sha")]
6574
rev: Sha,
6675

@@ -71,6 +80,7 @@ pub struct PinnedGitDependency {
7180

7281
/// Helper struct that represents a Git repository, with extra information about which folder to
7382
/// checkout.
83+
// TODO: how is this different from [UnpinnedGitDependency]?
7484
#[derive(Clone, Debug)]
7585
pub struct GitRepo {
7686
/// Repository URL
@@ -81,7 +91,8 @@ pub struct GitRepo {
8191
path: PathBuf,
8292
}
8393

84-
// Custom error type for SHA validation
94+
/// Custom error type for SHA validation
95+
// TODO: derive(Error)?
8596
#[derive(Debug)]
8697
pub enum ShaError {
8798
InvalidLength(usize),
@@ -133,6 +144,7 @@ impl GitRepo {
133144
self.rev.as_deref()
134145
}
135146

147+
// TODO: needs a comment
136148
pub fn package_set_path(&self) -> &PathBuf {
137149
&self.path
138150
}
@@ -163,13 +175,16 @@ impl GitRepo {
163175
}
164176

165177
/// Used for testing to be able to specify which folder to fetch to. Use `fetch` for all other needs.
178+
// TODO: should be non-pub
166179
pub async fn fetch_to_folder(&self, fetch_to_folder: PathBuf) -> PackageResult<PathBuf> {
167180
self.fetch_impl(Some(fetch_to_folder)).await
168181
}
169182

170183
/// Checkout the repository using a sparse checkout. It will try to clone without checkout, set
171184
/// sparse checkout directory, and then checkout the folder specified by `self.path` at the
172185
/// given sha.
186+
///
187+
// TODO think more about debug statements and what information to log
173188
async fn checkout_repo(&self, repo_fs_path: &PathBuf, sha: &str) -> PackageResult<()> {
174189
// Checkout repo if it does not exist already
175190
if !repo_fs_path.exists() {
@@ -267,6 +282,7 @@ impl GitRepo {
267282
}
268283

269284
/// Runs a git command from the provided arguments.
285+
// TODO: check for error codes here
270286
pub async fn run_git_cmd_with_args(
271287
&self,
272288
args: &[&str],
@@ -433,6 +449,8 @@ pub fn format_repo_to_fs_path(repo: &str, sha: &str, root_path: Option<PathBuf>)
433449

434450
/// Check if the given string is a valid commit SHA, i.e., 40 character long with only
435451
/// lowercase letters and digits
452+
///
453+
// TODO: rename this function to is_sha
436454
fn check_is_commit_sha(input: &str) -> bool {
437455
input.len() == 40
438456
&& input
@@ -448,6 +466,7 @@ fn url_to_file_name(url: &str) -> String {
448466
.to_string()
449467
}
450468

469+
// TODO: add more tests
451470
#[cfg(test)]
452471
mod tests {
453472
use super::*;

external-crates/move/crates/move-package-alt/src/dependency/local.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub struct LocalDependency {
1616
local: PathBuf,
1717
}
1818

19+
// TODO: dead code
1920
impl TryFrom<(&Path, toml_edit::Value)> for LocalDependency {
2021
type Error = anyhow::Error; // TODO
2122

0 commit comments

Comments
 (0)