theredditbandit / pman

A CLI project manager
Other
35 stars 3 forks source link

git version relies on local binary #43

Open ccoVeille opened 2 months ago

ccoVeille commented 2 months ago

https://github.com/theredditbandit/pman/blob/db003d5073b7fa982dc374d1e983aa347a2c98e5/pkg/utils/utils.go#L134

I would recommend using https://github.com/go-git/go-git

theredditbandit commented 2 months ago

This approach to get the version is actually flawed 😅.

I realized this as soon I merged #41 into master but the issue with this is , the git approach works when pman is run inside the pman repo and not outside it.

Also it relies on the end user having a copy of the pman source code that's up to date with remote.

I looked into an alternate approach that uses build flags while building the pman binary like so

#!/bin/bash

# Get the current commit tag or hash
version=$(git describe --tags --always)

# Build and install the application with the version information
go install -ldflags "-X main.version=${version}"

but have not gone ahead with that for now.

I have pushed a temporary fix in #42 for now that removes this approach and uses hard coded versioning.

ccoVeille commented 2 months ago

Oh I thought your code was about using git in each project to get metadata.

ccoVeille commented 2 months ago

About getting a nice version into cobra, you could use this

https://github.com/mszostok/version

theredditbandit commented 2 months ago

Oh I thought your code was about using git in each project to get metadata.

It was not , but it could be . . . maybe ? 😂

did you have any ideas about something that you would like to see in pman.

I am planning on adding a github style heatmap and a per-project todo list of sorts sometime later.

ccoVeille commented 2 months ago

Oh I thought your code was about using git in each project to get metadata.

It was not , but it could be . . . maybe ? 😂

did you have any ideas about something that you would like to see in pman.

I am planning on adding a github style heatmap and a per-project todo list of sorts sometime later.

It's what I thought about when I started using pman, I expected to see the number of starsh, uncommitted files, local commit, local branches. Currently it's a bit manual.

I also thought about features such as fork-cleaner, but in a local way. Like OK, I have nothing left with this project (and I have ways to know it's true) so I can safely delete a project.

https://github.com/caarlos0/fork-cleaner

I'm testing tons of projects locally.

Interesting things could also be about checking metadata such a project creation, last modified, last action in git (because it could differ if you switched branch), to sort project by activity

theredditbandit commented 2 months ago

About getting a nice version into cobra, you could use this

https://github.com/mszostok/version

I tried this , and it's really convenient too but it increased the binary size from 15M to 21M.

I feel just to print the version info this is too bulky.

theredditbandit commented 2 months ago

Oh I thought your code was about using git in each project to get metadata.

It was not , but it could be . . . maybe ? 😂 did you have any ideas about something that you would like to see in pman. I am planning on adding a github style heatmap and a per-project todo list of sorts sometime later.

It's what I thought about when I started using pman, I expected to see the number of starsh, uncommitted files, local commit, local branches. Currently it's a bit manual.

I also thought about features such as fork-cleaner, but in a local way. Like OK, I have nothing left with this project (and I have ways to know it's true) so I can safely delete a project.

https://github.com/caarlos0/fork-cleaner

I'm testing tons of projects locally.

Interesting things could also be about checking metadata such a project creation, last modified, last action in git (because it could differ if you switched branch), to sort project by activity

Thanks for the ideas! , I had not considered this but I'll be working to add more git based features and more stats and info about individual projects in the future.

regarding the local fork-cleaner feature. how would that work. I would prompt the user to delete certain project dirs if the repo hasn't seen any activity in x days ?

ccoVeille commented 2 months ago

About getting a nice version into cobra, you could use this

https://github.com/mszostok/version

I tried this , and it's really convenient too but it increased the binary size from 15M to 21M.

I feel just to print the version info this is too bulky.

Indeed, I didn't expect such a consequence in term of size.

BTW, I would like to recommend this tool if you are interested in following your binary size

https://github.com/Zxilly/go-size-analyzer ( :wave: @Zxilly )

ccoVeille commented 2 months ago

regarding the local fork-cleaner feature. how would that work. I would prompt the user to delete certain project dirs if the repo hasn't seen any activity in x days ?

I'm unsure. I would say it could be interesting to say something like no pending changes, no stash, no local branch.

I would say it's more something about the context.

Anyway, I'm also a bit afraid this kind of features would bring the tool in reinventing the wheel while other project exists to manage multi repositories. I don't have names here, I have never find them easy and safe to use.

For advanced usages on a project, I would use git-machete.

theredditbandit commented 2 months ago

Anyway, I'm also a bit afraid this kind of features would bring the tool in reinventing the wheel while other project exists to manage multi repositories. I don't have names here, I have never find them easy and safe to use.

For advanced usages on a project, I would use git-machete.

Yeah , I don't want to implement a full-fledged git client, we already have tools like git-machete and lazygit for that.

I think I'll stick to showing basic stats first like

ccoVeille commented 2 months ago

I agree with you. It's better to let the tool grow at your pace, and consider adding features as the people request for them via feature request