Include dependencies for certain COB actions

We ensure that for example, the given commits are fetched before the
revision or merge actions in a patch.
This commit is contained in:
Alexis Sellier 2023-04-12 13:36:23 +02:00
parent 489370dcbd
commit 97f076e3cf
No known key found for this signature in database
8 changed files with 52 additions and 21 deletions

View File

@ -250,7 +250,7 @@ So, let's fix this by running a rebase on the proposal's revision:
```
$ rad id rebase 3f6ae4f8645c8b0cbcd35ea924df7b13aca52774 --no-confirm
✓ Identity proposal '3f6ae4f8645c8b0cbcd35ea924df7b13aca52774' rebased 🌱
✓ Revision '42b9428df59ad349f706b1397750b75ea3b42574'
✓ Revision 'a6db848f8dba4ef2a9c16301e7d21ad87b707f1e'
title: Add Bob
description: Add Bob as a delegate
status: open
@ -293,9 +293,9 @@ Quorum Reached
We can now update the proposal to have both keys in the delegates set:
```
$ rad id update 3f6ae4f8645c8b0cbcd35ea924df7b13aca52774 --rev 42b9428df59ad349f706b1397750b75ea3b42574 --delegates did:key:z6MkedTZGJGqgQ2py2b8kGecfxdt2yRdHWF6JpaZC47fovFn --no-confirm
$ rad id update 3f6ae4f8645c8b0cbcd35ea924df7b13aca52774 --rev a6db848f8dba4ef2a9c16301e7d21ad87b707f1e --delegates did:key:z6MkedTZGJGqgQ2py2b8kGecfxdt2yRdHWF6JpaZC47fovFn --no-confirm
✓ Identity proposal '3f6ae4f8645c8b0cbcd35ea924df7b13aca52774' updated 🌱
✓ Revision '1b4ded759249e4f76d19c3e580b4736bf2a2d1c4'
✓ Revision '4bac5e3ef20e412e9421886fbb76dc7a64d6b5dc'
title: Add Bob
description: Add Bob as a delegate
status: open
@ -341,7 +341,7 @@ state of our new Radicle identity:
$ rad id show 3f6ae4f8645c8b0cbcd35ea924df7b13aca52774 --revisions
```
$ rad id accept 3f6ae4f8645c8b0cbcd35ea924df7b13aca52774 --rev 1b4ded759249e4f76d19c3e580b4736bf2a2d1c4 --no-confirm
$ rad id accept 3f6ae4f8645c8b0cbcd35ea924df7b13aca52774 --rev 4bac5e3ef20e412e9421886fbb76dc7a64d6b5dc --no-confirm
✓ Accepted proposal ✓
title: Add Bob
description: Add Bob as a delegate
@ -385,7 +385,7 @@ Quorum Reached
```
```
$ rad id commit 3f6ae4f8645c8b0cbcd35ea924df7b13aca52774 --rev 1b4ded759249e4f76d19c3e580b4736bf2a2d1c4 --no-confirm
$ rad id commit 3f6ae4f8645c8b0cbcd35ea924df7b13aca52774 --rev 4bac5e3ef20e412e9421886fbb76dc7a64d6b5dc --no-confirm
✓ Committed new identity '60de897bc24898f6908fd1272633c0b15aa4096f' 🌱
title: Add Bob
description: Add Bob as a delegate

View File

@ -84,16 +84,16 @@ $ git commit --message "Add README, just for the fun"
$ rad patch update --message "Add README, just for the fun" 191a14e520f2eeff7c0e3ee0a5523c5217eecb89
Updating 3e674d1 -> 27857ec
1 commit(s) ahead, 0 commit(s) behind
✓ Patch updated to revision 56a5efc062b34a97a162a3a4d4468ce3e7ba1c84
✓ Patch updated to revision c4ee2b105d8c43d090485b8997657cd3fc6af544
```
And let's leave a quick comment for our team:
```
$ rad comment 191a14e520f2eeff7c0e3ee0a5523c5217eecb89 --message 'I cannot wait to get back to the 90s!'
70fc8b18300096f6f0f919797457244e6e4b2cea
$ rad comment 191a14e520f2eeff7c0e3ee0a5523c5217eecb89 --message 'I cannot wait to get back to the 90s!' --reply-to 70fc8b18300096f6f0f919797457244e6e4b2cea
7a9f7a6358238f4ff115d2b2a5e522ab93867d38
3b25dcd534ed80c2b1f8b432bae6b2b00d89dfb2
$ rad comment 191a14e520f2eeff7c0e3ee0a5523c5217eecb89 --message 'I cannot wait to get back to the 90s!' --reply-to 3b25dcd534ed80c2b1f8b432bae6b2b00d89dfb2
f877693124903b7aab1d07f186f1a3ef95eb0c2a
```
Now, let's checkout the patch that we just created:
@ -118,7 +118,7 @@ $ rad patch
│ Define power requirements 191a14e R1 27857ec (flux-capacitor-power, patch/191a14e) ahead 2, behind 0 │
├──────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ ● opened by did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi (you) 3 months ago │
│ ↑ updated to 56a5efc062b34a97a162a3a4d4468ce3e7ba1c84 (27857ec) 3 months ago │
│ ↑ updated to c4ee2b105d8c43d090485b8997657cd3fc6af544 (27857ec) 3 months ago │
│ ✓ accepted by z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi (you) 3 months ago │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯
```

View File

@ -82,12 +82,12 @@ $ git commit --message "Add README, just for the fun"
$ rad patch update --message "Add README, just for the fun" a07ef7743a32a2e902672ea3526d1db6ee08108a
Updating 3e674d1 -> 27857ec
1 commit(s) ahead, 0 commit(s) behind
✓ Patch updated to revision 4f15eb5c994edd0bb6be29cb4801aa74308cc628
✓ Patch updated to revision 916d20252a36be611ca21427f4abce2d6397833c
```
And let's leave a quick comment for our team:
```
$ rad comment a07ef7743a32a2e902672ea3526d1db6ee08108a --message 'I cannot wait to get back to the 90s!'
73b006df6f494e6fb9f9b9e8ad152091fc25db69
eacda4ec25edcb89655774d08173858f0c05464c
```

View File

@ -31,7 +31,7 @@ $ rad patch
│ Define power requirements a07ef77 R1 27857ec ahead 2, behind 0 │
├───────────────────────────────────────────────────────────────────────────────────┤
│ ● opened by did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk 3 months ago │
│ ↑ updated to 4f15eb5c994edd0bb6be29cb4801aa74308cc628 (27857ec) 3 months ago │
│ ↑ updated to 916d20252a36be611ca21427f4abce2d6397833c (27857ec) 3 months ago │
╰───────────────────────────────────────────────────────────────────────────────────╯
```
@ -51,7 +51,7 @@ $ git commit --fixup HEAD~
$ rad patch update --message "Define power requirements" --message "See details." a07ef7743a32a2e902672ea3526d1db6ee08108a
Updating 27857ec -> f6484e0
1 commit(s) ahead, 0 commit(s) behind
✓ Patch updated to revision 737dc47d9eba730c5db8a8e33c41c7955f9093de
✓ Patch updated to revision a382489b0a6945cfe82d5df39703b4515c57731d
```
Great, all fixed up, lets merge the code.
@ -59,7 +59,7 @@ Great, all fixed up, lets merge the code.
```
$ git checkout master
Your branch is up to date with 'rad/master'.
$ rad merge 737dc47d9eba730c5db8a8e33c41c7955f9093de
$ rad merge a382489b0a6945cfe82d5df39703b4515c57731d
Merging a07ef77 R2 (f6484e0) by z6Mkt67…v4N1tRk into master (f2de534) via fast-forward...
Running `git merge --ff-only f6484e0f43e48a8983b9b39bf9bd4cd889f1d520`...
Updating f2de534..f6484e0
@ -81,8 +81,8 @@ $ rad patch --merged
│ Define power requirements a07ef77 R2 f6484e0 (flux-capacitor-power, master) ahead 3, behind 0 │
├───────────────────────────────────────────────────────────────────────────────────────────────┤
│ ● opened by did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk 3 months ago │
│ ↑ updated to 4f15eb5c994edd0bb6be29cb4801aa74308cc628 (27857ec) 3 months ago │
│ ↑ updated to 737dc47d9eba730c5db8a8e33c41c7955f9093de (f6484e0) 3 months ago │
│ ↑ updated to 916d20252a36be611ca21427f4abce2d6397833c (27857ec) 3 months ago │
│ ↑ updated to a382489b0a6945cfe82d5df39703b4515c57731d (f6484e0) 3 months ago │
│ ✓ merged by did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi (you) 3 months ago │
╰───────────────────────────────────────────────────────────────────────────────────────────────╯
```

View File

@ -119,7 +119,15 @@ impl change::Storage for git2::Repository {
ExtendedSignature::new(*key, sig)
};
let (id, timestamp) = write_commit(self, resource, tips, message, signature.clone(), tree)?;
let (id, timestamp) = write_commit(
self,
resource,
parents.clone(),
tips,
message,
signature.clone(),
tree,
)?;
Ok(Change {
id,
revision: revision.into(),
@ -231,6 +239,7 @@ fn load_contents(
fn write_commit<O>(
repo: &git2::Repository,
resource: O,
parents: Vec<O>,
tips: Vec<O>,
message: String,
signature: ExtendedSignature,
@ -242,6 +251,7 @@ where
let resource = *resource.as_ref();
let parents = tips
.iter()
.chain(parents.iter())
.map(|o| *o.as_ref())
.chain(std::iter::once(resource))
.collect::<Vec<_>>();

View File

@ -1953,7 +1953,7 @@ mod routes {
"reviews": [],
},
{
"id": "bdc0364b51a3346653a795b73332eb792283be37",
"id": "69cfd3fc589782afbcd47027c1172f8a55dd74c7",
"description": "This is a new revision",
"base": PARENT,
"oid": HEAD,

View File

@ -68,7 +68,16 @@ pub enum Action {
},
}
impl HistoryAction for Action {}
impl HistoryAction for Action {
fn parents(&self) -> Vec<Oid> {
match self {
Self::Revision { current, .. } => {
vec![*current]
}
_ => vec![],
}
}
}
/// Error applying an operation onto a state.
#[derive(Error, Debug)]

View File

@ -119,7 +119,19 @@ pub enum Action {
},
}
impl HistoryAction for Action {}
impl HistoryAction for Action {
fn parents(&self) -> Vec<git::Oid> {
match self {
Self::Revision { base, oid, .. } => {
vec![*base, *oid]
}
Self::Merge { commit, .. } => {
vec![*commit]
}
_ => vec![],
}
}
}
/// Where a patch is intended to be merged.
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]