MordechaiHadad / bob

A version manager for neovim
MIT License
1.41k stars 36 forks source link

[FIX] Store full commit hash in version sync file instead of short #205

Closed isak102 closed 3 months ago

isak102 commented 4 months ago

I regularly run into this problem when trying to use bob sync

❯ bob sync
Apr 27 11:56:08.087  INFO Starting sync process
Apr 27 11:56:08.087  INFO Using version 15c6909 set in /home/isak102/.local/share/chezmoi/dot_config/nvim/nvim.version
fatal: couldn't find remote ref 15c6909
Apr 27 11:56:08.553 ERROR Error: fetching remote failed, try providing the full commit hash

Is there any specific reason why the short hash is stored in the version sync file and not the full hash? If not, I am willing to open a PR to fix this

MordechaiHadad commented 4 months ago

Hello apologies for the delayed response, please go ahead. All you need to do is: go to this function here: https://github.com/MordechaiHadad/bob/blob/master/src/handlers/use_handler.rs#L55

and everywhere u see fs::write(..., &version.tag_name) change it so it checks if VersionType of version is hash pass the non_parsed_version otherwise pass tag_name

EDIT: you can create a var called file_version which will have an if clause which will either be tag_name or non_parsed_version depending on the VersionType

MordechaiHadad commented 4 months ago

@isak102 hello can you confirm this PR works for you?

isak102 commented 4 months ago

Thanks! Yes it is working

MordechaiHadad commented 4 months ago

Thanks! Yes it is working

Great I'll have to tweak it a bit before i can finally ship it since bob currently saves the build with the shortened hash which needs to be tweaked (ill probably write the full hash in a file.

isak102 commented 4 months ago

Yeah my bad, I didnt test actually opening Neovim, I just looked if it was saving the full hash in the file. When I try to open neovim I get this error

thread 'main' panicked at src/main.rs:97:14:
Failed to spawn child process: Os { code: 2, kind: NotFound, message: "No such file or directory" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
MordechaiHadad commented 4 months ago

Yeah my bad, I didnt test actually opening Neovim, I just looked if it was saving the full hash in the file. When I try to open neovim I get this error

thread 'main' panicked at src/main.rs:97:14:
Failed to spawn child process: Os { code: 2, kind: NotFound, message: "No such file or directory" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

ye lol

MordechaiHadad commented 3 months ago

@isak102 It should work now, the steps to test is:

  1. Copy newest bob version to nvim-bin
  2. Remove the old binary
  3. Rename the copy to nvim
  4. Use bob use <hash> (if it gives an error to already built version add file called full-hash.txt with the full hash of the commit to the root directory of the version)
  5. Execute neovim like you would normally.
MordechaiHadad commented 3 months ago

@isak102 have you tried the latest commits of this PR?

isak102 commented 2 months ago

@isak102 have you tried the latest commits of this PR?

Sorry, I have been a bit busy with thesis and stuff lately so I missed this. But it works perfectly, thanks!