Repository navigation
Add check for attempts to commit >100 MB files without Git LFS - #6013
Conversation
This function returns whether or not Git LFS is set up. This will be used to check whether or not to display a warning when committing files larger than 100 MB.
This function retrieves an array of paths to any files that are included for a commit that are over 100 MB. This will be used to display a warning to users who do not have Git LFS set up and are trying to commit large files.
Passed the function that retrieves the paths of files to be included in a commit that are over 100 MB down to Commit-Message via props. This will allow calling this function when attempting to commit, so that a check can be done for any potential large file issues when Git LFS is not set up.
This function returns a list of file paths that are over 100 MB if Git LFS is not supported. It will return an empty array if LFS is supported.
This is a new dialog that has been created to display a list of files that are over 100 MB to the user when they are attempting to commit large files without having Git LFS set up. It provides the warning and information on Git LFS and offers the opportunity to cancel the commit or commit anyway.
…rge files createCommit now will detect when the user is committing files larger than 100 MB and Git LFS is not set up and display a warning to the user informing them of the situation and allowing them to either cancel the commit or commit anyways.
Previously the checkForLargeFiles() function would return an empty array if GitLFS was supported. This was not an obvious behavior to expect, and did not make too much sense. Instead, the function will expect that if the function is called you wish to always get the same functionality. This means that the check is expected to be run before deciding to call the function.
Commit-Message's createCommit function will now prepare the variables necessary to create a commit and pass them to the OversizedFileWarning popup dialog so that a user can create the commit with the "Commit Anyway" button.
In both the cirumstance that the OversizedFilesWarning popup dialog is shown and the createCommit function immediately returns as well as simply continuing with the commit requires the same variables. Previously each route retrieved them separately which was not necessary. Instead they are now retrieved earlier and are available for both situations.
With this change this function expects a promise from the FSE API and makes the getNamesOfSelectedOversizedFiles function async and also return a promise. This allows us to stop using the .statSync function which is against the eslint rules.
When an error occurs while trying to get the file size of any of the selected working directory files then it will now be logged.
| : summary, | ||
| : summary | ||
|
|
||
| const lfsSupported = await this.checkForLFS() |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
Tentatively dropping this from the |
|
@Daniel-McCarthy As @shiftkey mentioned above, we talked this morning about this one and we're really excited about it, but we don't want to rush it into next week's release. It feels like it'll be important to have it out on beta for a decent period of time to make sure it's working as expected. So it'll likely go into 1.5.x and be available for all users in 1.6. |
|
@billygriffin Sounds great! That's certainly no problem. I see no reason to rush it and expected it might need a decent bit of review and test time since it is so closely tied with core functionality of committing. |
shiftkey
left a comment
There was a problem hiding this comment.
Some initial feedback - I've prefixed the aesthetic changes with 🎨 to indicate those suggestions are more about the readability of the code. Let me know if anything is unclear.
The OversizedFilesWarning dialog needs access to the dispatcher to be able to initiate a commit. Previously commit-message passed the dispatcher in to be sent along to the dialog in App.tsx. But since App.tsx already has access to the dispatcher it is sufficient to simply pass it in from App.tsx and avoid the pre-emptive passing.
Previously this name was not very descriptive so has been renamed to explain a bit about what kind of files these are and their relation to the dialog that makes use of it.
Previously this function looped through all of the working directory files and detected if they were included for a pending commit. Instead, they are now prefiltered and will loop through files that are already known to be included.
The path list now uses Monospaced and PathText to render the path list to handle long file paths and trim them to fit in one line. The dialog has also had some styling changes to accomodate for the new text sizes and ensuring the consistency.
|
@Daniel-McCarthy and @shiftkey a few questions regarding testing:
|
@tierninho It means they won’t be able to push to GitHub, effectively leaving them in the same place as they are today. We don’t want to block their progress if there’s some reason they want to commit these large files anyway, but we do want to make it clear that it will subsequently prevent them from pushing to GitHub. If you think the verbiage in the warning doesn’t adequately convey that, we can discuss altering it a bit. |
|
@Daniel-McCarthy this is looking good to me! i think the only thing left to do is address this outstanding todo:
see #6049 and #6097 specifically as a guide and let me know if you have any questions! ⛷ I'd love to get this in soon-ish (if possible) since i'm starting to write something similar for #6213 (checking for conflicts when hitting the commit button) 😄 |
|
@outofambit Sounds great. I'd love to get that implemented and have this ready to go. However I did have some trouble with it. I tried using However, on my end, although it runs and sets the message to null and runs |
|
@Daniel-McCarthy i've reproduced this locally and am working on a fix since its not caused by anything in your pr. will update (soon) when i have more info. |
|
@Daniel-McCarthy this worked for me: private commitAnyway = async () => {
const context = this.props.context
await this.props.dispatcher.commitIncludedChanges(
this.props.repository,
context
)
this.props.dispatcher.setCommitMessage(this.props.repository, {
summary: '',
description: null,
})
await this.props.dispatcher.closePopup()
}looks like that produces different behavior from |
Previously after creating a commit with the commit anyway button the commit message would be left uncleared. This was not ideal as it would be expected to be cleared since it is no longer needed. Now it will be cleared before closing the dialog popup. Co-Authored-By: outofambit <[email protected]>
|
@outofambit That is wonderful, thank you for the help! Thanks again, I really appreciate the assistance! |
Previously the completion of the commit creation was not awaited. This means the popup would close and the commit summary would be cleared while it is committing. The result of this was that the commit summary would now display as the default commit summary while it's committing, appearing as though it is not the entered summary. This was done so that the popup could be closed before the completion of the commit creation allowing the user to see the program commit as normal. Now, the popup is closed first so that awaiting commit creation does not effect the popup closing.
|
Hey @Daniel-McCarthy! We'd love to call out your contribution on this in the release blog post for 1.6. Would it be ok if we mention you using your handle? |
|
@billygriffin Of course, that's perfectly acceptable. |
|
Is there a way to automatically ignore files over the limit size? I don't see the logic behind trying to push and then causing a nasty error thats hard to reset. Why can't I just write a flag in my gitignore by file size like file type? Right now I can tell LFS to LFS files by type, but thats very manual. I am looking for functionality that lets me simply flip a flag and never have to deal with file size issues again. |
Overview
Closes #997
Description
This pull request aims to display a pop-up to notify the user in situations where they are committing files larger than 100 MB and do not have Git LFS set up.
The implementation of this extends the standard commit button behavior. When the commit button is pressed it will now check if Git LFS is set up. If so, it will commit normally. If not, it will proceed to check if any of the selected files to commit are over 100 MB in size.
If none are then it will commit normally. If not, it will display a new Popup Dialog called the
OversizedFilesWarningwhich informs the user of the situation and offer two options: (1. Cancel the commit. (2. Commit anyway.Currently if a user commits a large file over 100 MB and does not have Git LFS set up, they will get an error when attempting to push to their GitHub remote repository. Often times the user may not have been aware of the size of the file and now in themselves not able to push anymore.
This solution aims to warn users before they get stuck not being able to push and warn them early.
Currently this implementation supports creating a commit for the user from within the dialog via the
Commit Anywaybutton. However, normally when the commit button is pressed the commit message and commit summary will be cleared after the commit. This functionality does not currently occur when committing from the dialog due to complications mentioned in original issue.@outofambit has opted to address this in another pull request. Thanks again!
Release notes
Notes: Added dialog to check for oversized file issues that would prevent pushing to the remote repository.