Flutter-Bounty-Hunters / static_shock

A static site generator for Dart.
MIT License
58 stars 5 forks source link

Add pubspec.lock to .gitignore #132

Closed suragch closed 3 weeks ago

suragch commented 3 weeks ago

Dart frequently updates pubspec.lock. When multiple developers are fetching and pushing changes to a shared repo, pubspec.lock is a common source of merge conflicts. It also pollutes the PR, making it harder to review.

Reproduction steps:

  1. Run dart pub get after any project dependency has changed.
  2. Add and commit changes with git.
  3. Open a PR on the upstream repo.

Expected result:

The PR should omit any local changes to pubspec.lock. The static_shock repo should not include pubspec.lock files at all.

Actual result:

The PR includes pubspec.lock (potentially more than one, since static_shock includes multiple packages).

Resolving ambiguities

This PR could be resolved by adding pubspec.lock to .gitignore. In fact, this is the recommendation for libraries in the Dart documentation.

Committing pubspec.lock to source control may perhaps be useful at times for an application where all of the developers need to ensure that they are building exactly the same binary. However, for shared libraries it is better for everyone to create their pubspec.lock files locally.

I'm not suggesting we add pubspec.lock to the .gitignore of generated projects, only to the static_shock repo itself.

I am suggesting we specifically add pubspec.lock to the .gitignore at the top level. Adding it to sub-packages is also fine, but would be unnecessary if it were already included at the top level. The reason for this is that it's easy to forget when adding another package. For example, packages/static_shock includes it while the other packages omit it. Apparently that was just an oversight.