cli: Some improvements to `rad merge`
This commit is contained in:
parent
c3e14c346b
commit
b6fa4a4b2a
|
|
@ -3,7 +3,7 @@ The `rad inspect` command can be run without being authenticated with radicle:
|
|||
```
|
||||
$ rad self
|
||||
✗ Self failed: Could not load radicle profile
|
||||
✗ To setup your radicle profile, run `rad auth`.
|
||||
✗ Hint: To setup your radicle profile, run `rad auth`.
|
||||
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -82,10 +82,9 @@ $ git commit --message "Add README, just for the fun"
|
|||
1 file changed, 0 insertions(+), 0 deletions(-)
|
||||
create mode 100644 README.md
|
||||
$ rad patch update --message "Add README, just for the fun" 191a14e520f2eeff7c0e3ee0a5523c5217eecb89
|
||||
191a14e R0 (3e674d1) -> R1 (27857ec)
|
||||
Updating 3e674d1 -> 27857ec
|
||||
1 commit(s) ahead, 0 commit(s) behind
|
||||
|
||||
✓ Patch 191a14e updated to 56a5efc062b34a97a162a3a4d4468ce3e7ba1c84
|
||||
✓ Patch updated to revision 56a5efc062b34a97a162a3a4d4468ce3e7ba1c84
|
||||
```
|
||||
|
||||
And let's leave a quick comment for our team:
|
||||
|
|
@ -119,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 191a14e520f2eeff7c0e3ee0a5523c5217eecb89 (3e674d1) 3 months ago │
|
||||
│ ↑ updated to 56a5efc062b34a97a162a3a4d4468ce3e7ba1c84 (27857ec) 3 months ago │
|
||||
│ ✓ accepted by z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi (you) 3 months ago │
|
||||
╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
```
|
||||
|
|
|
|||
|
|
@ -80,10 +80,9 @@ $ git commit --message "Add README, just for the fun"
|
|||
1 file changed, 0 insertions(+), 0 deletions(-)
|
||||
create mode 100644 README.md
|
||||
$ rad patch update --message "Add README, just for the fun" a07ef7743a32a2e902672ea3526d1db6ee08108a
|
||||
a07ef77 R0 (3e674d1) -> R1 (27857ec)
|
||||
Updating 3e674d1 -> 27857ec
|
||||
1 commit(s) ahead, 0 commit(s) behind
|
||||
|
||||
✓ Patch a07ef77 updated to 4f15eb5c994edd0bb6be29cb4801aa74308cc628
|
||||
✓ Patch updated to revision 4f15eb5c994edd0bb6be29cb4801aa74308cc628
|
||||
```
|
||||
|
||||
And let's leave a quick comment for our team:
|
||||
|
|
|
|||
|
|
@ -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 a07ef7743a32a2e902672ea3526d1db6ee08108a (3e674d1) 3 months ago │
|
||||
│ ↑ updated to 4f15eb5c994edd0bb6be29cb4801aa74308cc628 (27857ec) 3 months ago │
|
||||
╰───────────────────────────────────────────────────────────────────────────────────╯
|
||||
```
|
||||
|
||||
|
|
@ -49,10 +49,9 @@ $ git commit --fixup HEAD~
|
|||
1 file changed, 0 insertions(+), 0 deletions(-)
|
||||
rename REQUIREMENTS => REQUIREMENTS.md (100%)
|
||||
$ rad patch update --message "Define power requirements" --message "See details." a07ef7743a32a2e902672ea3526d1db6ee08108a
|
||||
a07ef77 R1 (27857ec) -> R2 (f6484e0)
|
||||
Updating 27857ec -> f6484e0
|
||||
1 commit(s) ahead, 0 commit(s) behind
|
||||
|
||||
✓ Patch a07ef77 updated to 737dc47d9eba730c5db8a8e33c41c7955f9093de
|
||||
✓ Patch updated to revision 737dc47d9eba730c5db8a8e33c41c7955f9093de
|
||||
```
|
||||
|
||||
Great, all fixed up, lets merge the code.
|
||||
|
|
@ -61,7 +60,7 @@ Great, all fixed up, lets merge the code.
|
|||
$ git checkout master
|
||||
Your branch is up to date with 'rad/master'.
|
||||
$ rad merge 737dc47d9eba730c5db8a8e33c41c7955f9093de
|
||||
Merging a07ef77 R2 (f6484e0) by did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk into master (f2de534) via fast-forward...
|
||||
Merging a07ef77 R2 (f6484e0) by z6Mkt67…v4N1tRk into master (f2de534) via fast-forward...
|
||||
Running `git merge --ff-only f6484e0f43e48a8983b9b39bf9bd4cd889f1d520`...
|
||||
Updating f2de534..f6484e0
|
||||
Fast-forward
|
||||
|
|
@ -82,8 +81,8 @@ $ rad patch
|
|||
│ Define power requirements a07ef77 R2 f6484e0 (flux-capacitor-power, master) ahead 3, behind 0 │
|
||||
├───────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ ● opened by did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk 3 months ago │
|
||||
│ ↑ updated to a07ef7743a32a2e902672ea3526d1db6ee08108a (3e674d1) 3 months ago │
|
||||
│ ↑ updated to 4f15eb5c994edd0bb6be29cb4801aa74308cc628 (27857ec) 3 months ago │
|
||||
│ ↑ updated to 737dc47d9eba730c5db8a8e33c41c7955f9093de (f6484e0) 3 months ago │
|
||||
│ ✓ merged by did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi (you) 3 months ago │
|
||||
╰───────────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
```
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
|||
term::format::tertiary(term::format::cob(&patch_id)),
|
||||
term::format::dim(format!("R{revision_ix}")),
|
||||
term::format::parens(term::format::secondary(term::format::oid(revision.head()))),
|
||||
term::format::tertiary(patch.author().id),
|
||||
term::format::tertiary(term::format::node(&patch.author().id)),
|
||||
term::format::highlight(branch),
|
||||
term::format::parens(term::format::secondary(term::format::oid(head_oid))),
|
||||
merge_style_pretty
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ fn print(
|
|||
&patch.timestamp(),
|
||||
)));
|
||||
|
||||
let (latest, revision) = patch
|
||||
let (_, revision) = patch
|
||||
.latest()
|
||||
.ok_or_else(|| anyhow!("patch is malformed: no revisions found"))?;
|
||||
let mut widget = term::VStack::default()
|
||||
|
|
@ -101,7 +101,7 @@ fn print(
|
|||
let mut timeline = Vec::new();
|
||||
for (revision_id, revision) in patch.revisions() {
|
||||
// Don't show an "update" line for the first revision.
|
||||
if revision_id != latest {
|
||||
if **revision_id != **patch_id {
|
||||
timeline.push((
|
||||
revision.timestamp(),
|
||||
term::Line::spaced(
|
||||
|
|
|
|||
|
|
@ -28,13 +28,11 @@ fn select_patch(
|
|||
find_unmerged_with_base(*head_oid, *target_oid, base_oid, patches, workdir, whoami)?;
|
||||
|
||||
let Some((id, _, _)) = result.pop() else {
|
||||
term::blank();
|
||||
anyhow::bail!("No patches found to update, please open a new patch or specify the patch id manually");
|
||||
anyhow::bail!("No patches found to update, please specify a patch id");
|
||||
};
|
||||
|
||||
if !result.is_empty() {
|
||||
term::blank();
|
||||
anyhow::bail!("More than one patch available to update, please specify an id with `rad patch --update <id>`");
|
||||
anyhow::bail!("More than one patch available to update, please specify a patch id");
|
||||
}
|
||||
term::blank();
|
||||
|
||||
|
|
@ -43,24 +41,15 @@ fn select_patch(
|
|||
|
||||
fn show_update_commit_info(
|
||||
workdir: &git::raw::Repository,
|
||||
patch_id: &patch::PatchId,
|
||||
patch: &patch::Patch,
|
||||
current_revision: &patch::Revision,
|
||||
head_branch: &git::raw::Branch,
|
||||
) -> anyhow::Result<()> {
|
||||
// TODO(cloudhead): Handle error.
|
||||
let current_version = patch.version();
|
||||
let head_oid = branch_oid(head_branch)?;
|
||||
|
||||
term::info!(
|
||||
"{} {} {} -> {} {}",
|
||||
term::format::tertiary(term::format::cob(patch_id)),
|
||||
term::format::dim(format!("R{current_version}")),
|
||||
term::format::parens(term::format::secondary(term::format::oid(
|
||||
current_revision.head()
|
||||
))),
|
||||
term::format::dim(format!("R{}", current_version + 1)),
|
||||
term::format::parens(term::format::secondary(term::format::oid(head_oid))),
|
||||
"Updating {} -> {}",
|
||||
term::format::secondary(term::format::oid(current_revision.head())),
|
||||
term::format::secondary(term::format::oid(head_oid)),
|
||||
);
|
||||
|
||||
// Difference between the two revisions.
|
||||
|
|
@ -70,7 +59,7 @@ fn show_update_commit_info(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Run patch creation.
|
||||
/// Run patch update.
|
||||
pub fn run(
|
||||
storage: &Repository,
|
||||
profile: &Profile,
|
||||
|
|
@ -102,7 +91,7 @@ pub fn run(
|
|||
return Ok(());
|
||||
}
|
||||
|
||||
show_update_commit_info(workdir, &patch_id, &patch, current_revision, &head_branch)?;
|
||||
show_update_commit_info(workdir, current_revision, &head_branch)?;
|
||||
|
||||
let head_oid = branch_oid(&head_branch)?;
|
||||
let base_oid = workdir.merge_base(*target_oid, *head_oid)?;
|
||||
|
|
@ -110,10 +99,8 @@ pub fn run(
|
|||
let signer = term::signer(profile)?;
|
||||
let revision = patch.update(message, base_oid, *head_oid, &signer)?;
|
||||
|
||||
term::blank();
|
||||
term::success!(
|
||||
"Patch {} updated to {}",
|
||||
term::format::highlight(term::format::cob(&patch_id)),
|
||||
"Patch updated to revision {}",
|
||||
term::format::tertiary(revision),
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
// This file is part of radicle-link, distributed under the GPLv3 with Radicle
|
||||
// Linking Exception. For full terms see the included LICENSE file.
|
||||
use std::fmt;
|
||||
use std::ops::Deref;
|
||||
use std::str::FromStr;
|
||||
|
||||
use git_ext::Oid;
|
||||
|
|
@ -67,6 +68,14 @@ impl From<&EntryId> for object::ObjectId {
|
|||
}
|
||||
}
|
||||
|
||||
impl Deref for EntryId {
|
||||
type Target = Oid;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
/// One entry in the dependency graph for a change
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct Entry {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// This file is part of radicle-link, distributed under the GPLv3 with Radicle
|
||||
// Linking Exception. For full terms see the included LICENSE file.
|
||||
|
||||
use std::{convert::TryFrom as _, fmt, str::FromStr};
|
||||
use std::{convert::TryFrom as _, fmt, ops::Deref, str::FromStr};
|
||||
|
||||
use git_ext::Oid;
|
||||
use git_ref_format::{Component, RefString};
|
||||
|
|
@ -62,6 +62,14 @@ impl From<&git2::Oid> for ObjectId {
|
|||
}
|
||||
}
|
||||
|
||||
impl Deref for ObjectId {
|
||||
type Target = Oid;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ObjectId {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", self.0)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use crate::{style, Paint};
|
|||
pub use inquire::Select;
|
||||
|
||||
pub const ERROR_PREFIX: Paint<&str> = Paint::red("✗");
|
||||
pub const ERROR_HINT_PREFIX: Paint<&str> = Paint::yellow("✗");
|
||||
pub const ERROR_HINT_PREFIX: Paint<&str> = Paint::yellow("✗ Hint:");
|
||||
pub const WARNING_PREFIX: Paint<&str> = Paint::yellow("!");
|
||||
pub const TAB: &str = " ";
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ pub enum Error {
|
|||
#[error("git: {0}")]
|
||||
Git(#[from] git2::Error),
|
||||
#[error("invalid repository identifier {0:?}")]
|
||||
Id(std::ffi::OsString),
|
||||
InvalidId(std::ffi::OsString),
|
||||
#[error("i/o: {0}")]
|
||||
Io(#[from] io::Error),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,7 +156,8 @@ impl Storage {
|
|||
if path.file_name().to_string_lossy().starts_with('.') {
|
||||
continue;
|
||||
}
|
||||
let rid = Id::try_from(path.file_name()).map_err(|_| Error::Id(path.file_name()))?;
|
||||
let rid =
|
||||
Id::try_from(path.file_name()).map_err(|_| Error::InvalidId(path.file_name()))?;
|
||||
let repo = self.repository(rid)?;
|
||||
|
||||
// For performance reasons, we don't do a full repository check here.
|
||||
|
|
|
|||
Loading…
Reference in New Issue