-
-
Notifications
You must be signed in to change notification settings - Fork 63
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 git-only option #1227
base: main
Are you sure you want to change the base?
Conversation
use std::collections::BTreeMap; | ||
|
||
lazy_static::lazy_static! { | ||
// match PR/issue numbers, e.g. `#123` |
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.
is this comment true?
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.
oops no, that was a copy-paste error
@jdidion How about this PR? I am interested in this feature. If you need help, I would be very glad to join. |
@giangndm sure that would be great. I can add you as a collaborator on my fork. I'd you have a good plan for finishing the implementation go for it. |
Hey guys, don't misunderstand this as pressure, but it's been a long time. If you want my help, I think I can contribute to finalizing this PR. Best! |
That would be great, thanks! I'll add you as a contributor. |
To let everyone know and manage expectations: due to unforeseen new tasks and a business trip to Singapore, I'll be available after March 15th. Will gladly help the issue if you guys still need help at that time. |
Got my hands dirty with implementing returning |
Any updates on this? What else is required? |
@ozgunozerk the big outstanding issue is implementing |
8673768
to
9795c58
Compare
@MarcoIeni @ozgunozerk I introduced the |
Great work! I've made the code more idiomatic, and also fixed the lifetime / borrow checker issues. I believe we only have 3 unimplemented logics, and then I guess this will be ready for review, what do you think @MarcoIeni? Sorry for being lazy, but I prefer asking the question here instead of going through the code of the whole repository:
I did not touch the empty implementations because I believe I don't have the full details on what to implement there. If the big-picture is supplied, I can get down to coding the solution. |
Hey, thanks for working on this! I'll do my best to support you and get this shipped 🚀
From this code:
I guess the base package can be either:
In case of git_only option true, we need to compare:
I suggest to keep the base package in a separate directory, so you can compare the two repositories. You can do |
Ah, silly me! I confused myself that we will be comparing the git repo with the git repo, hence it did not make sense at first (brainfart moment). We will compare the checked out code at git repo, with the release in git repo, makes sense! If I have time, I may start implementing the remaining unimplemented ones in the weekend! |
Hi again! Finally found the time to inspect all the codebase, and here is the plan that I come up with: Plan: The only remaining thing is to find the latest previous release in the github, and parse it's cargo.toml and cargo.lock file for the comparison. Then, we will just call the existing functions (which are handling the actual comparison process) in this crate with the parsed toml and lock file, and it should be good to go. Problems: However, I believe there are some inconsistencies in the code base. If my understanding it correct, I believe a minor PR prior to this one would be helpful. Below are my findings: @MarcoIeni, this one is from the original code base:
So, the wording should be changed. We have two options afaik:
@jdidion this one is from your suggested changes:
If I understand your intentions correctly, you parsed the latest release's name and version, but did not parse the content of it yet. What I suggest is
I made a lot of assumptions here, it'd be best to get confirmations before I proceed. |
Thanks for working on this!
why do we use github releases instead of git tags?
I don't get why there's an inconsistency. The log info doesn't name crates.io
Yeah, you are right. With "registry" package, I mean "remote" package or similar. What do you think is a better term? Anyway, let's keep this term for now and refactor in another pr to avoid making this pr too big.
I think the name of that struct RepoVersions is misleading. RepoVersions contains the names of the packages and their most recent versions.
Isn't this RepoVersions?
yes!
I don't get why is this needed. But maybe I'm missing something, so if you think this is needed, go ahead 👍 |
Appreciate the fast response @MarcoIeni! Diving right into your questions/feeback 👀
I choose the word
Yep, my bad on that. No worries about this one! 👍
I think
Absolutely, and I wrote: "I believe a minor PR prior to this one would be helpful". It was not my intention to include multiple things in a single PR. Let me elaborate on that: it was confusing for me to went through the codebase whilst being not sure on whether It's your call though :)
I believe so! Wanted to get confirmation from @jdidion if he had the same design in his mind.
Hmm, this may be the most important discussion point. So, how can we compare the packages of the registry (downloaded from remote git), with the local one (to be released one)? From what I understood (for the crates.io default workflow),
If we do not parse the toml and lock file of the latest release in git registry, how can we generate these diff's? As usual, feel free to correct me on any of the above if I'm missing anything |
I'm not too sure about this.
For this reason, I would use git tags instead of github releases. Also, git tags work across git hosts (github, gitlab, etc.).
My preference goes to adding the functionality first and refactoring it later so that we can ship the functionality earlier without arguing about names 😅. But if you prefer to open a refactoring pr before working on this, I won't stop you :)
You can re-use the existing algorithm:
P.S. sorry about the new merge conflicts! 😅 |
That's what I meant by parsing cargo.lock and cargo.toml, I'm so glad it is already implemented, that's fantastic 🥳
No worries, I'm quite used to resolving those 👍 Agreed on tags instead of releases, I'm convinced! And ok, considering that the other PR might take some time due to potential discussions, I'll follow your suggestion and finish this one first, let's get down to work 🤓 |
…nt BasePackage functions for git-only case
2db4664
to
2d86112
Compare
I have to take a break, but here is the summary:
@MarcoIeni @jdidion
The reasons on why I got confused on
|
I documented the function in #1381
If the comparison logic doesn't need to know, we must ensure every package "looks like" a registry package.
Probably running
yes, probably you are right, if we do it this way, we can simplify the comparison logic 👍 Unless there's some corner case I'm not thinking about right now.
yes
Hopefully #1381 clarifies it a bit. |
Ok, here is my proposed change, if @jdidion also agrees with it, I can push my commit. However it is overriding quite a big chunk of the work @jdidion did, so I wanted to get his opinion first. This is the new pub fn next_versions(input: &UpdateRequest) -> anyhow::Result<(PackagesUpdate, TempRepo)> {
let overrides = input.packages_config.overrides.keys().cloned().collect();
let local_project = Project::new(
&input.local_manifest,
input.single_package.as_deref(),
overrides,
&input.metadata,
input,
)?;
let updater = Updater {
project: &local_project,
req: input,
};
let repository = local_project
.get_repo()
.context("failed to determine local project repository")?;
if !input.allow_dirty {
repository.repo.is_clean()?;
}
// NEW CODE BEGIN
if input.packages_config.default.git_only && input.registry_manifest.is_none() {
debug!("git-only feature is enabled, and no registry manifest supplied. Will try to fetch the manifest from the latest tag");
match get_repo_versions(
&repository.repo,
local_project.contains_multiple_pub_packages,
)
.context("could not get tag versions from the repo")?
{
Some(RepoVersions::Single(version)) => {
repository.repo.checkout(version.to_string().as_str())?;
// TODO:
// 1. find the manifest (cargo.toml) file in this repo
// 2. use it to override the `None` value for `registry_manifest`:
// input.registry_manifest = Some(latest_tag_registry_manifest)
repository.repo.checkout_head()?;
}
Some(RepoVersions::ByPackage(_b_tree_map)) => {
unimplemented!("I don't know how this will work with multiple packages")
}
None => {
unimplemented!("means that there is no previous tag in the repo. What should we do in this case?")
}
}
}
// NEW CODE END
let registry_packages = registry_packages::get_registry_packages(
input.registry_manifest.as_deref(),
&local_project.publishable_packages(),
input.registry.as_deref(),
)?;
let packages_to_update =
updater.packages_to_update(®istry_packages, &repository.repo, input.local_manifest())?;
Ok((packages_to_update, repository))
} Rest of the |
No description provided.