Skip to content

Add check for attempts to commit >100 MB files without Git LFS - #6013

Merged
outofambit merged 30 commits into
desktop:masterfrom
Daniel-McCarthy:Add-OverSize-File-Check
Dec 12, 2018
Merged

outofambit merged 30 commits into
desktop:masterfrom
Daniel-McCarthy:Add-OverSize-File-Check

Conversation

@Daniel-McCarthy

Copy link
Copy Markdown
Member

Overview

Closes #997

Description

  • What:

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.


  • How:

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.


  • Why:

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.


  • Additional information:

Currently this implementation supports creating a commit for the user from within the dialog via the Commit Anyway button. 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.

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.
@outofambit outofambit added the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Oct 27, 2018
@outofambit outofambit added this to the 1.5.0 milestone Oct 27, 2018
Comment thread app/src/ui/changes/changes-list.tsx Resolved
Comment thread app/src/ui/changes/changes-list.tsx Resolved
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.
Comment thread app/src/ui/changes/commit-message.tsx Outdated
: summary,
: summary

const lfsSupported = await this.checkForLFS()

This comment was marked as spam.

@shiftkey shiftkey removed this from the 1.5.0 milestone Oct 29, 2018
@shiftkey

Copy link
Copy Markdown
Member

Tentatively dropping this from the 1.5.0 milestone as we've only just started the review and we might be pushing ourselves to get this baked on beta sufficiently before the 7th (when we're aiming to ship this) along with the other items in our milestone.

@billygriffin

Copy link
Copy Markdown
Contributor

@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.

@Daniel-McCarthy

Copy link
Copy Markdown
Member Author

@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 shiftkey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread app/src/models/popup.ts Resolved
Comment thread app/src/models/popup.ts Resolved
Comment thread app/src/models/popup.ts Resolved
Comment thread app/src/ui/app.tsx Resolved
Comment thread app/src/ui/changes/changes-list.tsx Resolved
Comment thread app/src/ui/changes/changes-list.tsx Resolved
@shiftkey shiftkey self-assigned this Oct 29, 2018
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.
@tierninho

Copy link
Copy Markdown
Contributor

@Daniel-McCarthy and @shiftkey a few questions regarding testing:

  • Do you know of a way to toggle off/on LFS or at least trick Desktop? I've been using Dev Tools > Application > Local Storage to change values but not sure if it will be recorded here.
  • For the commit anyway button, does this mean GitHub will now allow 100+ MB files even if the user does not have LFS ... however there is no turning back? I imagine github/github would have to make allowance changes for this?
  • Do limits apply for Enterprise accounts as well?

@billygriffin

Copy link
Copy Markdown
Contributor

For the commit anyway button, does this mean GitHub will now allow 100+ MB files even if the user does not have LFS ... however there is no turning back? I imagine github/github would have to make allowance changes for this?

@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.

@outofambit

Copy link
Copy Markdown
Contributor

@Daniel-McCarthy this is looking good to me! i think the only thing left to do is address this outstanding todo:

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.

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
outofambit removed their request for review December 9, 2018 02:46
@Daniel-McCarthy

Copy link
Copy Markdown
Member Author

@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 setCommitMessage with a null message argument like in your previous pull request.

However, on my end, although it runs and sets the message to null and runs emitUpdate, the summary is never cleared in the UI. I haven't been able to get it to work so far.

@outofambit

Copy link
Copy Markdown
Contributor

@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.

@outofambit

Copy link
Copy Markdown
Contributor

@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 null, which is not good. i'll file an issue for us to fix that. this should get you going in the meantime though! thanks!!

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]>
@Daniel-McCarthy

Copy link
Copy Markdown
Member Author

@outofambit That is wonderful, thank you for the help!
I tested this and it works great on my end as well. I have made the commit and will push it now.

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.

@outofambit outofambit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✨

@billygriffin

Copy link
Copy Markdown
Contributor

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?

@Daniel-McCarthy

Copy link
Copy Markdown
Member Author

@billygriffin Of course, that's perfectly acceptable.
Thanks for the consideration! I'm quite happy that these changes have landed and hope they will help users in the future!

@rcyost

rcyost commented Feb 25, 2024 •

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants