git.__remotes_from_dir() should only return lists
PATCH 1/1 git.__remotes_from_dir() should only return lists
If there are no remotes, return empty list, not None. The later doesn't work with builtin set().
This fixes t1001-branch-rename.sh
---
stgit/git.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
stgit/git.py +1 -1
@@ -953,7 +953,7 @@ def __remotes_from_dir(dir): if os.path.exists(d): return os.listdir(d) else: - return None + return [] def remotes_list(): """Return the list of remotes in the repository
Quoted 2 lines · Pavel Roskin
If there are no remotes, return empty list, not None. The later doesn't work with builtin
set().
Thanks. But I guess an even nicer fix would be to make this function return a set in the first place.
Quoted 1 line
This fixes
t1001-branch-rename.sh
Hmm. I don't believe I saw t1001 break without this patch (I run the test suite before I push, but I might have made a mistake of course). Does the user's environment leak into the test sandbox?
Signature · 2 lines
Karl Hasselström, [email protected] www.treskal.com/kalle
Quoted 7 lines · Karl Hasselström
Quoted 2 lines · Pavel Roskin
If there are no remotes, return empty list, not None. The later doesn't work with builtin
set().Thanks. But I guess an even nicer fix would be to make this function return a set in the first place.
Fine with me. But it was returning a list or None, so the simplest fix was to return a list in all cases.
Quoted 5 lines
Quoted 1 line
This fixes
t1001-branch-rename.shHmm. I don't believe I saw t1001 break without this patch (I run the test suite before I push, but I might have made a mistake of course). Does the user's environment leak into the test sandbox?
I don't think it's the user environment, at least on my side. I'm using Fedora 7, which has python-2.5-12.fc7. That's the error from the t1001 before my patch:
Traceback (most recent call last):
File "/home/proski/src/stgit/t/../stg", line 43, in <module>
main()
File "/home/proski/src/stgit/stgit/main.py", line 284, in main
command.func(parser, options, args)
File "/home/proski/src/stgit/stgit/commands/branch.py", line 163, in func
parentremote = git.identify_remote(parentbranch)
File "/home/proski/src/stgit/stgit/git.py", line 994, in identify_remote
for remote in remotes_list():
File "/home/proski/src/stgit/stgit/git.py", line 963, in remotes_list
| set(__remotes_from_dir('branches')))TypeError: 'NoneType' object is not iterable
Signature · 2 lines
Regards, Pavel Roskin
Quoted 7 lines · Pavel Roskin
Quoted 2 lines · Karl Hasselström
Thanks. But I guess an even nicer fix would be to make this function return a set in the first place.
Fine with me. But it was returning a list or None, so the simplest fix was to return a list in all cases.
Oh, your fix is excellent to fix the immediate problem. I was just trying to say that making this function (an a heap of others) return sets would be a useful refactoring.
Quoted 7 lines
Quoted 3 lines
Hmm. I don't believe I saw t1001 break without this patch (I run the test suite before I push, but I might have made a mistake of course). Does the user's environment leak into the test sandbox?
I don't think it's the user environment, at least on my side. I'm using Fedora 7, which has python-2.5-12.fc7. That's the error from the t1001 before my patch:
OK. I'll try to reproduce it when I get home, but it certainly looks like I only _thought_ I'd run the test suite.
Signature · 2 lines
Karl Hasselström, [email protected] www.treskal.com/kalle
Quoted 9 lines · Pavel Roskin
Quoted 3 lines · Karl Hasselström
Hmm. I don't believe I saw t1001 break without this patch (I run the test suite before I push, but I might have made a mistake of course). Does the user's environment leak into the test sandbox?
I don't think it's the user environment, at least on my side. I'm using Fedora 7, which has python-2.5-12.fc7. That's the error from the t1001 before my patch:
Mmm, irritating. I really don't get the error, and debug printouts confirm that it's because the directories .git/remotes and .git/branches both exist.
Your patch is the right thing to do anyway, obviously.
Signature · 2 lines
Karl Hasselström, [email protected] www.treskal.com/kalle