Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
igaray committed Jun 14, 2018
1 parent 72910d5 commit fd11cf7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions name_pryer.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def __init__(self):
self.recursive = False
self.directory = os.getcwd()
self.pattern = None
self.git_mode = False


class Action:
Expand Down Expand Up @@ -331,13 +332,21 @@ def rename_file(config, old, new):
try:
if old == new:
return True
if new == "":
print("Warning: attempt to rename file to empty name: {}", old)
return False
if config.git_mode:
subprocess.call(["git", "mv", old, new])
subprocess.run(["git", "mv", old, new], check=True)
else:
os.renames(old, new)
return True
except Exception:
except CalledProcessError as e:
print("error while git renaming {} to {}",format(old, new))
print("error:", e)
return False
except Exception as e:
print("error while renaming {} to {}".format(old, new))
print("error: ", e)
return False


Expand Down

0 comments on commit fd11cf7

Please sign in to comment.