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

🐛 Bug Report: publish:github:pull-request does not support deletion of files #28112

Open
2 tasks done
Lock128 opened this issue Dec 11, 2024 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@Lock128
Copy link

Lock128 commented Dec 11, 2024

📜 Description

When I use the scaffolder action 'publish:github:pull-request' in a template this does not support the "deletion" of files that where previously in the git repository

it should support that

👍 Expected behavior

If I checkout a repository, remove a file and then create a pull request the pull request should actually have a file deletion marker for this file and merging the PR should delete this.

👎 Actual Behavior with Screenshots

The created PR in Github is "empty" - no files are visible in it....

👟 Reproduction steps

Using this template

  steps:
    - action: fetch:plain
      id: fetch-plain
      name: Fetch plain
      input:
        url: https://${{ parameters.repoUrl | parseRepoUrl | pick('host') }}/${{ parameters.repoUrl | parseRepoUrl | pick('owner') }}/${{ parameters.repoUrl | parseRepoUrl | pick('repo') }}
    - id: log
      name: Current files in directory
      action: debug:log
      input:
        listWorkspace: true
    - action: fs:delete
      id: delete-file
      name: Delete files
      input:
        files:
          - "file-to-delete.yaml"
    - id: log2
      name: New files in directory
      action: debug:log
      input:
        listWorkspace: true
    - id: pullRequest
      name: Pull Request
      action: publish:github:pull-request
      input:
        repoUrl: ${{ parameters.repoUrl }}
        branchName: delete-dt-${{ parameters.name }}
        description: "Delete file"
        gitCommitMessage: "Delete file ${{ parameters.name }}"
        title: "Deletes a file"

📃 Provide the context for the Bug.

This is where the files are read

const files = Object.fromEntries(
directoryContents.map(file => [
targetPath ? path.posix.join(targetPath, file.path) : file.path,
{
// See the properties of tree items
// in https://docs.github.com/en/rest/reference/git#trees
mode: determineFileMode(file),
// Always use base64 encoding where possible to avoid doubling a binary file in size
// due to interpreting a binary file as utf-8 and sending github
// the utf-8 encoded content. Symlinks are kept as utf-8 to avoid them
// being formatted as a series of scrambled characters
//
// For example, the original gradle-wrapper.jar is 57.8k in https://github.com/kennethzfeng/pull-request-test/pull/5/files.
// Its size could be doubled to 98.3K (See https://github.com/kennethzfeng/pull-request-test/pull/4/files)
encoding: determineFileEncoding(file),
content: file.content.toString(determineFileEncoding(file)),
},
]),
);

and then they are added to the PR here:

obviously, a file that was deleted will never be added as a "change set" :-(

🖥️ Your Environment

No response

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Are you willing to submit PR?

No, but I'm happy to collaborate on a PR with someone else

@Lock128 Lock128 added the bug Something isn't working label Dec 11, 2024
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

No branches or pull requests

1 participant