goldstar611 / gitless

A maintained fork of the simple git interface
https://goldstar611.github.io/gitless/
MIT License
26 stars 2 forks source link

Improve gl pull and gl fetch #34

Closed sirlucjan closed 2 years ago

sirlucjan commented 2 years ago

A small change that will make gl fetch and gl pull similar to other gitless commands

Signed-off-by: Piotr Gorski lucjan.lucjanov@gmail.com

sirlucjan commented 2 years ago

The only thing needed now is to add pprint.err in case something goes wrong.

goldstar611 commented 2 years ago

The only thing needed now is to add pprint.err in case something goes wrong.

It's looking good. I pushed some basic tests to your branch also. Thanks for your contributions :)

sirlucjan commented 2 years ago

I will try to add prrint.err in the near future if necessary.

goldstar611 commented 2 years ago

I will try to add prrint.err in the near future if necessary.

I can add it for you, just let me know. I'm also happy to leave the PR open until you get around to it.

sirlucjan commented 2 years ago

If I could ask for a suggestion - how would you resolve this pprint.err?

goldstar611 commented 2 years ago

If I could ask for a suggestion - how would you resolve this pprint.err?

Since we have the variable p what I would do is

if p.returncode == 0:
    pprint.ok('Fetching from upstream succeeded')
else:
    pprint.err("Fetching from upstream failed")

[Edit] Sorry I mixed single and double quotes. It looks like the style here is single quotes. :D

sirlucjan commented 2 years ago
if p.returncode == 0:
    pprint.ok('Fetching from upstream succeeded')
else:
    pprint.err("Fetching from upstream failed")

It doesn't seem to be working all the way.

  File "/usr/bin/gl", line 33, in <module>
    sys.exit(load_entry_point('gitless==0.9.16', 'console_scripts', 'gl')())
  File "/usr/bin/gl", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 162, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/lib/python3.10/site-packages/gitless/cli/gl.py", line 17, in <module>
    from . import (
  File "/usr/lib/python3.10/site-packages/gitless/cli/gl_fetch.py", line 26
    pprint.ok('Fetching from upstream succeeded')
    ^
IndentationError: expected an indented block after 'if' statement on line 25
goldstar611 commented 2 years ago

It doesn't seem to be working all the way.

I can't see all of the changes but you might need more spaces before that pprint.ok line. You'll need 4 spaces to make it part of the if statement.

sirlucjan commented 2 years ago

It doesn't seem to be working all the way.

I can't see all of the changes but you might need more spaces before that pprint.ok line. You'll need 4 spaces to make it part of the if statement.

Indeed. I gave too many spaces.

Now I got another error.

  File "/usr/bin/gl", line 33, in <module>
    sys.exit(load_entry_point('gitless==0.9.16', 'console_scripts', 'gl')())
  File "/usr/bin/gl", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 162, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/lib/python3.10/site-packages/gitless/cli/gl.py", line 17, in <module>
    from . import (
  File "/usr/lib/python3.10/site-packages/gitless/cli/gl_fetch.py", line 25, in <module>
    if p.returncode == 0:
NameError: name 'p' is not defined
sirlucjan commented 2 years ago

I added a commit for the overview. At this hour (4 in the morning) a person is no longer thinking logically. Maybe I'll deal with this later.

goldstar611 commented 2 years ago

I added a commit for the overview. At this hour (4 in the morning) a person is no longer thinking logically. Maybe I'll deal with this later.

You were really, really close. I've pushed the fix and the tests back to your branch. I'll merge it shortly after the tests run.

diff --git a/gitless/cli/gl_fetch.py b/gitless/cli/gl_fetch.py
index d6a5a9f..3143f3a 100644
--- a/gitless/cli/gl_fetch.py
+++ b/gitless/cli/gl_fetch.py
@@ -22,7 +22,7 @@ def parser(subparsers, _):

 def main(args, repo):
     p = core.git_wrap('fetch', *args.fetch_args)
-if p.returncode == 0:
-    pprint.ok('Fetching from upstream succeeded')
-else:
-    pprint.err('Fetching from upstream failed')
+    if p.returncode == 0:
+        pprint.ok('Fetching from upstream succeeded')
+    else:
+        pprint.err('Fetching from upstream failed')