-
-
Notifications
You must be signed in to change notification settings - Fork 86
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 support for revsets #175
Labels
enhancement
New feature or request
Comments
This probably won't be helpful, but FWIW I hacked around a little bit last night was able to get this working w/ the following changes in +use gitrevset::SetExt;
pub fn resolve_commits<'repo>(
effects: &Effects,
repo: &'repo Repo,
dag: &mut Dag,
hashes: Vec<String>,
) -> eyre::Result<ResolveCommitsResult<'repo>> {
let mut commits = Vec::new();
+
+ // FIXME can we share the already opened git2::Repository from repo.inner?
+ let git_repo = git2::Repository::open(repo.get_path())?;
+ let revset_repo = gitrevset::Repo::open_from_repo(Box::new(git_repo))?;
+
for hash in hashes {
- let commit = match repo.revparse_single_commit(&hash)? {
+ let set = revset_repo.anyrevs(hash.as_str())?;
+
+ for oid in set.to_oids()? {
+ // FIXME yuck: oid -> to_string -> as_str ???
+ let commit = match repo.revparse_single_commit(oid?.to_string().as_str())? {
let commit = match repo.revparse_single_commit(&hash)? {
Some(commit) => commit,
None => return Ok(ResolveCommitsResult::CommitNotFound { commit: hash }),
};
commits.push(commit)
}
+ }
let commit_oids = commits.iter().map(|commit| commit.get_oid()).collect_vec();
dag.sync_from_oids(
effects,
repo,
CommitSet::empty(),
CommitSet::from_iter(commit_oids.into_iter().map(CommitVertex::from).map(Ok)),
)?;
Ok(ResolveCommitsResult::Ok { commits })
} Not pretty and theres room for much improvement, but it was fun to play with and this was enough to get something like |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See discussion at #157.
The text was updated successfully, but these errors were encountered: