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 a real progress bar in clone-git-repo@anaximeno #280

Open
carlosmintfan opened this issue Mar 23, 2024 · 3 comments
Open

Show a real progress bar in clone-git-repo@anaximeno #280

carlosmintfan opened this issue Mar 23, 2024 · 3 comments
Labels
feature request New feature or request

Comments

@carlosmintfan
Copy link
Contributor

Action name and maintainer

clone-git-repo@anaximeno @anaximeno

What would you like to see?

Hi @anaximeno,
thanks for your action! Do you plan to add a real progress bar that shows progress instead of just switching its location without showing real progress?

@carlosmintfan carlosmintfan added the feature request New feature or request label Mar 23, 2024
@anaximeno
Copy link
Contributor

Hello @carlosmintfan,

I don't plan to show real progress for now, because as far as I have researched there is no easy way to get the general progress (in an easily interpretable format) using the git command, there might be other ways to get that info though, like parsing the output at each specific phase, but that will take more time and complexity than what I am willing to attribute to this for now.

@h3nr1ke
Copy link
Contributor

h3nr1ke commented Apr 26, 2024

Hi, I was wondering if we can do something like this other lib does

https://github.com/steveukx/git-js

in this file

https://github.com/steveukx/git-js/blob/f5196e9df243e722642f0da877e721c5d32852b1/simple-git/src/lib/plugins/progress-monitor-plugin.ts

they are parsing the output of the process and generating an event so the user is able to track it

maybe it can give us some inspiration

@anaximeno
Copy link
Contributor

Hi, I was wondering if we can do something like this other lib does

https://github.com/steveukx/git-js

in this file

https://github.com/steveukx/git-js/blob/f5196e9df243e722642f0da877e721c5d32852b1/simple-git/src/lib/plugins/progress-monitor-plugin.ts

they are parsing the output of the process and generating an event so the user is able to track it

maybe it can give us some inspiration

Hi, that might be a viable solution for this, I may take some time to try to implement this in the future, but if you want to try this before that, you are open to sending a PR here.

In the line below I read an 8-character chunk from the cloning process stderr with self._process.stderr.read(8).decode("utf-8") and add it to an output buffer to construct the full output of the process at a given instance and then display the last line in the stderr:

self._buff += self._process.stderr.read(8).decode("utf-8")
window.progressbar.set_text(roverride(self._buff.split("\n")[-1]))

The roverride is useful here because the output comes escaped there so I use the override to apply the \b which is a string code to apply an override from right to left on the string when displayed to the stdout (similar to the \n which is used to display a new line).

def roverride(string: str) -> str:
overrides = string.split("\r")
overriden = overrides[0]
for override in overrides[1:]:
l = len(override)
overriden = override + overriden[l:]
return overriden

So probably the chunk that should be sent to the regex would be the result of the roverride(self._buff.split("\n")[-1]).

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

No branches or pull requests

3 participants