#44 os.chdir should be avoid
Closed 7 years ago Opened 8 years ago by cqi.

In pyrpkg/__init__.py, os.chdir is used to change to git repository to perform git and other operations. This makes code hard to understand a little and be errorprone. os.chdir should be avoid as much as possible. For example, in pyrpkg.Commands.diff, current directory is changed to self.path, and then perform git diff, that can be replace with using --git-dir.


This is a worthwhile thing to fix. When a program needs to run in changed working directory, we could just set cwd via the function in subprocess. This would work even if the program does not have an option like --git-dir.

We can't just remove os.chdir from pyrpkg. There may be downstream users who rely on working directory being changed.

RHBZ#1353699 is related to this issue.

I'm going to close this. Feel free reopen if it's necessary to fix in the future.

@cqi changed the status to Closed

7 years ago

Login to comment on this ticket.

Metadata