Skip to content
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

Show Commit Hash When Using ya pack -l #1881

Closed
3 tasks done
yudai0804 opened this issue Nov 2, 2024 · 3 comments · Fixed by #1884
Closed
3 tasks done

Show Commit Hash When Using ya pack -l #1881

yudai0804 opened this issue Nov 2, 2024 · 3 comments · Fixed by #1884
Labels
feature New feature request good first issue Good for newcomers

Comments

@yudai0804
Copy link
Contributor

yazi --debug output

Yazi
    Version: 0.3.3 (7c445ce 2024-09-04)
    Debug  : false
    OS     : linux-x86_64 (unix)

Ya
    Version: 0.3.3 (7c445ce 2024-09-04)

Emulator
    Emulator.via_env: ("xterm-256color", "WezTerm")
    Emulator.via_csi: Ok(WezTerm)
    Emulator.detect : WezTerm

Adapter
    Adapter.matches: Iterm2

Desktop
    XDG_SESSION_TYPE           : Some("wayland")
    WAYLAND_DISPLAY            : Some("wayland-0")
    DISPLAY                    : Some(":1")
    SWAYSOCK                   : None
    HYPRLAND_INSTANCE_SIGNATURE: None
    WAYFIRE_SOCKET             : None

SSH
    shared.in_ssh_connection: false

WSL
    WSL: false

Variables
    SHELL              : Some("/usr/bin/bash")
    EDITOR             : Some("vim")
    VISUAL             : None
    YAZI_FILE_ONE      : None
    YAZI_CONFIG_HOME   : None

Text Opener
    default: Some(Opener { run: "${EDITOR:-vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })
    block  : Some(Opener { run: "${EDITOR:-vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })

Multiplexers
    TMUX               : false
    tmux version       : No such file or directory (os error 2)
    ZELLIJ_SESSION_NAME: None
    Zellij version     : No such file or directory (os error 2)

Dependencies
    file             : 5.44
    ueberzugpp       : No such file or directory (os error 2)
    ffmpegthumbnailer: No such file or directory (os error 2)
    magick           : No such file or directory (os error 2)
    fzf              : 0.54.1
    fd               : No such file or directory (os error 2)
    rg               : 13.0.0
    chafa            : 1.12.4
    zoxide           : 0.9.6
    7z               : 16.02
    7zz              : No such file or directory (os error 2)
    jq               : 1.6


--------------------------------------------------
When reporting a bug, please also upload the `yazi.log` log file - only upload the most recent content by time.
You can find it in the "/home/user/.local/state/yazi" directory.

Please describe the problem you're trying to solve

When the ya pack -l command is executed, it shows the username and repository name.
I think that showing only the username and repository name is not very helpful.
So, I would like to show the commit hash as well.
Showing the commit hash is easy because it is written in package.toml.
It seems that it can be accomplished just by modifying yazi-cli/src/package/parser.rs.

pub(crate) async fn list_from_config(section: &str) -> Result<()> {
let path = Xdg::config_dir().join("package.toml");
let Ok(s) = fs::read_to_string(&path).await else {
return Ok(());
};
let doc = s.parse::<DocumentMut>().context("Failed to parse package.toml")?;
let Some(deps) = doc.get(section).and_then(|d| d.get("deps")) else {
return Ok(());
};
let deps = deps.as_array().context("`deps` must be an array")?;
println!("{section}s:");
for dep in deps {
if let Some(Value::String(use_)) = dep.as_inline_table().and_then(|t| t.get("use")) {
println!("\t{}", use_.value());
}
}
Ok(())
}

Would you be willing to contribute this feature?

  • Yes, I'll give it a shot

Describe the solution you'd like

current format

user/repo

I want to show the following format

user/repo (hash)

I would like to contribute, but I am a Rust beginner.
So it may take time.

I appreciate your help.

Additional context

No response

Validations

  • I have searched the existing issues/discussions
  • The latest nightly build doesn't already have this feature
@yudai0804 yudai0804 added the feature New feature request label Nov 2, 2024
@yudai0804
Copy link
Contributor Author

In the future, I would like to display the commit message.
And I am also interested in implementing that feature.

@sxyazi
Copy link
Owner

sxyazi commented Nov 3, 2024

Nice to have!

To achieve this we need to add a new rev field getting process alongside the existing use, and print it out here:

if let Some(Value::String(use_)) = dep.as_inline_table().and_then(|t| t.get("use")) {
println!("\t{}", use_.value());
}

@yudai0804 Would you like to give it a go?

@sxyazi sxyazi added the good first issue Good for newcomers label Nov 3, 2024
@yudai0804
Copy link
Contributor Author

Thank you!
I'll try it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants