-
Notifications
You must be signed in to change notification settings - Fork 3
Add support for deleted and moved files #55
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
Conversation
5c13f6c to
2757e65
Compare
|
Ideally i'd like to add some tests, but I dont know typescript well enough to implement those given that everything seems to be just un exported functions. Also no idea what the typescript way of mocking/testing the filesystem + git would be 🤔 for now I've tested it similar to the test workflow locally (in my private org where i have an app already setup) and everything seems to work updating the test workflow to show case the rename + delete support would require doing either 2 rounds of commits in the workflow or permanently committing test files so i skipped that for now |
2757e65 to
66d85ee
Compare
66d85ee to
6c3f896
Compare
|
@abannachGrafana does this look like a reasonable approach to solving #55 to you? |
|
@max-frank I apologize for being a terrible maintainer and not catching this sooner. I've got another PR to simplify this action #57 to use the graphql api. Which has deletions added, but haven't worked on renames just yet. I'll see if I can add that as well. Your approach looks correct though. Renames are essentially delete old file add new file same contents. I'm including it in my PR. |
Example usage- name: Commit changes
uses: grafana/github-api-commit-action@077642073699d6dd9e9c42a9f69ce517fabf79d2 # v0.3.0
with:
commit-message: "<commit-message>" # Commit message defaults to "Commit performed by grafana/github-api-commit-action"
create-branch-on-remote: true # Whether to create the branch on the remote if it doesn't exist already: Defaults to false
stage-all-files: true # Whether to additionally stage any changed files in the checkout. Defaults to false
token: ${{ secrets.GITHUB_TOKEN }} # Token you want to authenticate with, must have write permission to repoFor now I'll close this PR since I've removed any typescript/node code from it. Thanks for the help! |
No worries, thanks for your open source work ;) I'll switch from my fork to your new version using graphql and will report back should I run into any issues |
WHAT
SSIA
WHY
Details
By switching to using
--name-statusinstead of--name-onlyfor retrieving the diff it becomes possible to differentiate between the 4 cases.An example output with all 4 cases would look like this
With this its easy to parse the output
DMR<\d\d\d>(the number is the sameness percentage between the new and old file)AFor
MandAwe can keep the same logic that already exists. ForDwe simply create a tree node withshaset tonull, this indicates a deletion for the API. In the context of the APIRis simply adeletefor the old file path and aaddfor the new one.