Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deletion of a file does not trigger the sync action. #68

Closed
Leocete opened this issue Jul 13, 2021 · 5 comments · Fixed by #69
Closed

Deletion of a file does not trigger the sync action. #68

Leocete opened this issue Jul 13, 2021 · 5 comments · Fixed by #69
Assignees
Labels
bug Something isn't working

Comments

@Leocete
Copy link
Contributor

Leocete commented Jul 13, 2021

🐞 Describe the bug

Deletion of a file does not trigger the sync action.

📚 To Reproduce

  1. Configure repo sync action on a particular directory
  2. Add some files there.
  3. Delete one of the files.

💡 Expected behavior

A new PR opened with file deletion.

🖼️ Screenshots

If applicable, add screenshots to help explain your problem.

⚙️ Environment

  • Action version: [e.g. v1.0.0]

📋 Additional context

Add any other context about the problem here.

@Leocete Leocete added the bug Something isn't working label Jul 13, 2021
@Leocete
Copy link
Contributor Author

Leocete commented Jul 13, 2021

A problem is here in that command:

`git status --porcelain`,

It somehow can't see deleted files.

@BetaHuhn
Copy link
Owner

BetaHuhn commented Jul 13, 2021

Hey @Leocete,

Thanks for taking the time to open this issue!

It somehow can't see deleted files.

git status --porcelain should list all deleted files as well.

The problem is repo-file-sync-action currently can't delete files when syncing two directories. This is not documented anywhere explicitly, which was not ideal on my part.

It only copies files which exist in the source directory to their target destination and creates a commit if there were any changes. It thus doesn't delete any files in the target directory. As you can see here:

const isDirectory = await pathIsDirectory(file.source)
const source = isDirectory ? `${ addTrailingSlash(file.source) }` : file.source
if (isDirectory) core.warning(`Source is directory`)
await copy(source, localDestination, file.exclude)

The copying itself is done with fs-extra.

I currently have no fix for this, so you are welcome to propose ideas on how we can implement this in an elegant way!

@BetaHuhn
Copy link
Owner

One way to fix this would be to get all files for both the source and target and then figure out which files should be copied from the source to the target and which files should be deleted from the target.

Right now it just merges the source directory with the target.

@BetaHuhn BetaHuhn self-assigned this Jul 13, 2021
@Leocete
Copy link
Contributor Author

Leocete commented Jul 14, 2021

I opened a PR on that issue - #69

@BetaHuhn BetaHuhn linked a pull request Jul 14, 2021 that will close this issue
@BetaHuhn
Copy link
Owner

🎉 This issue is resolved in version v1.9.0 🎉

You have to enable deleting files in the target manually with the deleteOrphaned option.

To use the latest version, use the Action with the v1 tag:

uses: BetaHuhn/repo-file-sync-action@v1

Or the latest tag:

uses: BetaHuhn/repo-file-sync-action@latest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants