Skip to content

self update を実装する#41

Merged
zztkm merged 5 commits intomainfrom
feature/self-update
Nov 9, 2025
Merged

self update を実装する#41
zztkm merged 5 commits intomainfrom
feature/self-update

Conversation

@zztkm
Copy link
Copy Markdown
Member

@zztkm zztkm commented Nov 9, 2025

No description provided.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @zztkm, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

このプルリクエストは、vssツールにセルフアップデート機能をもたらします。これにより、ユーザーはコマンドラインから直接ツールを最新の状態に保つことができ、手動でのダウンロードやインストール作業が不要になります。新しいselfサブコマンドを通じて、更新の実行や現在のバージョン情報の確認が可能となり、ツールの使いやすさとメンテナンス性が向上します。

Highlights

  • セルフアップデート機能の追加: vssツールにセルフアップデート機能が実装されました。これにより、コマンドラインから直接ツールを最新バージョンに更新できるようになります。
  • 新しいselfサブコマンド: セルフアップデート関連の操作を行うための新しいselfサブコマンドが追加されました。これにはupdateversionの2つのサブコマンドが含まれます。
  • updateサブコマンド: vss self updateコマンドを実行することで、GitHub Releasesから最新のバイナリをダウンロードし、現在の実行ファイルを置き換えることができます。
  • versionサブコマンド: vss self versionコマンドを実行することで、現在のvssのバージョン、コミットハッシュ、およびプラットフォーム情報を表示できます。
  • 依存関係の追加: セルフアップデート機能を実現するために、self_updateクレートとその多くの推移的な依存関係がCargo.tomlCargo.lockに追加されました。
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/release.yaml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

セルフアップデート機能の実装、ありがとうございます。全体的なアプローチは良いですが、エラーハンドリングに関して改善できる点がいくつか見つかりました。特に、update サブコマンドの実装には、コンパイルエラーを引き起こす可能性のあるクリティカルな問題と、未サポートの環境でパニックを引き起こす問題があります。また、self サブコマンドのルーター部分では、より idiomatic なエラーの返し方があります。各コメントで具体的な修正案を提案していますので、ご確認ください。

Comment on lines +12 to +30
pub fn run(_args: noargs::RawArgs) -> noargs::Result<()> {
println!("最新バージョンを確認しています...");

match update() {
Ok(status) => {
if status.updated() {
println!("✓ vss を {} に更新しました", status.version());
println!("\n変更を適用するには、コマンドを再実行してください。");
} else {
println!("✓ すでに最新バージョン ({}) です", status.version());
}
Ok(())
}
Err(e) => {
eprintln!("更新に失敗しました: {}", e);
std::process::exit(1);
}
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

この run 関数は noargs::Result<()> を返すように宣言されていますが、現在の実装では成功時に暗黙的に () を返してしまい、コンパイルエラーになる可能性があります。また、エラー時に std::process::exit(1) を直接呼び出すのは、呼び出し元でのエラーハンドリングを妨げるため、避けるべきです。

match 式全体を関数の戻り値とし、エラーケースでは noargs::Error を返すように修正することをお勧めします。これにより、コードがより idiomatic になり、エラー処理が一貫します。

pub fn run(_args: noargs::RawArgs) -> noargs::Result<()> {
    println!("最新バージョンを確認しています...");

    match update() {
        Ok(status) => {
            if status.updated() {
                println!("✓ vss を {} に更新しました", status.version());
                println!("\n変更を適用するには、コマンドを再実行してください。");
            } else {
                println!("✓ すでに最新バージョン ({}) です", status.version());
            }
            Ok(())
        }
        Err(e) => Err(noargs::Error::new(format!("更新に失敗しました: {}", e))),
    }
}

Comment on lines +40 to +51
fn get_target() -> &'static str {
let os = std::env::consts::OS;
let arch = std::env::consts::ARCH;

match (os, arch) {
("linux", "x86_64") => "linux_amd64",
("linux", "aarch64") => "linux_arm64",
("macos", "aarch64") => "darwin_arm64",
("windows", "x86_64") => "windows_amd64",
_ => panic!("Unsupported platform: {} {}", os, arch),
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

サポートされていないプラットフォームで panic! する代わりに、Result を返してエラーを適切に処理するべきです。panic! はプログラムをクラッシュさせ、ユーザーフレンドリーなエラーメッセージを表示できません。

get_targetanyhow::Result<&'static str> を返すように変更し、呼び出し元の update 関数 (55行目) で let target = get_target()?; のように ? 演算子を使ってエラーを伝播させることをお勧めします。

fn get_target() -> anyhow::Result<&'static str> {
    let os = std::env::consts::OS;
    let arch = std::env::consts::ARCH;

    match (os, arch) {
        ("linux", "x86_64") => Ok("linux_amd64"),
        ("linux", "aarch64") => Ok("linux_arm64"),
        ("macos", "aarch64") => Ok("darwin_arm64"),
        ("windows", "x86_64") => Ok("windows_amd64"),
        _ => Err(anyhow::anyhow!("Unsupported platform: {} {}", os, arch)),
    }
}

Comment thread src/subcommand_self.rs
Comment on lines +12 to +19
} else {
eprintln!("使用方法: vss self [update|version]");
eprintln!();
eprintln!("サブコマンド:");
eprintln!(" update - {}", UPDATE_COMMAND.doc);
eprintln!(" version - {}", VERSION_COMMAND.doc);
std::process::exit(1);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

std::process::exit(1) を直接呼び出す代わりに、noargs::Error を返してエラー処理を main 関数に委ねるのがより idiomatic です。これにより、アプリケーション全体でエラー処理の方法が一貫します。

Suggested change
} else {
eprintln!("使用方法: vss self [update|version]");
eprintln!();
eprintln!("サブコマンド:");
eprintln!(" update - {}", UPDATE_COMMAND.doc);
eprintln!(" version - {}", VERSION_COMMAND.doc);
std::process::exit(1);
}
} else {
let help_text = format!(
"使用方法: vss self [update|version]\n\nサブコマンド:\n update - {}\n version - {}",
UPDATE_COMMAND.doc,
VERSION_COMMAND.doc
);
return Err(noargs::Error::new(help_text));
}

@zztkm zztkm merged commit ea275ab into main Nov 9, 2025
4 checks passed
@zztkm zztkm deleted the feature/self-update branch November 9, 2025 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant