jlevy / jlevy/repren

Log warnings when rename collisions occur (numeric suffix added)

Open
#44 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
374
Forks
39
Avg merge
3m
Merged PRs (30d)
1

Description

## Summary

When a file rename would clobber an existing file, `move_file()` silently adds numeric suffixes (`.1`, `.2`, etc.) to avoid the collision. No log message is emitted, so users have no visibility into this happening.

## Details

In `repren.py`, the `move_file()` function (line 767) handles collisions by incrementing a numeric suffix, but the caller (`transform_file`) doesn't log when this happens. There is a TODO at line 1637 acknowledging this: `# Log collisions`.

This can be confusing when a user runs repren and the output file has an unexpected `.1` suffix with no explanation.

## Suggestion

Add a log message when a collision is detected and a numeric suffix is applied, e.g.:

```
- collision: target 'foo.txt' already exists, writing to 'foo.txt.1'
```

This is especially important in `--full` mode where multiple renames could collide.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.