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

Poll for Git repository hash and set isOutdated when it changes #31

Merged
merged 16 commits into from
Aug 16, 2023

Conversation

ghengeveld
Copy link
Member

@ghengeveld ghengeveld commented Aug 10, 2023

This generates a single hash representing the current state of the Git repository, and sends a channel event whenever the hash changes. The panel sets isOutdated: true whenever it receives the event.

There are a bunch more improvements on this PR, including a fix to how the Tool and Panel synchronize state, how/when the "run tests" button shows a spinner/is disabled, a fix to prevent the UI from flickering while polling, and a tweak to never stop polling for build/tests.

📦 Published PR as canary version: 0.0.22--canary.31.f264f7e.0

✨ Test out this PR locally via:

npm install @chromaui/addon-visual-tests@0.0.22--canary.31.f264f7e.0
# or 
yarn add @chromaui/addon-visual-tests@0.0.22--canary.31.f264f7e.0

@linear
Copy link

linear bot commented Aug 10, 2023

AP-3369 Add concept of outdated builds

  • Store a "git changes" hash as well as the commit hash on the build (ideally in the index, but it could be locally).
    • The CLI could understand the concept of a "uncommitted builds" also.
  • Poll git for the current commit hash + changes hash (we also need to poll for branch for AP-3366 eventually)
  • Consider snapshots out of date if the two don't match.

To get a hash of staged+unstaged+untracked changes:

(
 git diff --name-only --diff-filter=d --cached; 
 git diff --name-only --diff-filter=d; 
 git ls-files --others --exclude-standard
) | git hash-object --stdin-paths | git hash-object --stdin

This seems to be the only way to get a full hash of all these types of changes, whilst excluding any deleted files (which would cause an error because they can't be hashed).

@ghengeveld ghengeveld changed the title Retrieve Git repository hash at an interval and set isOutdated when it changes Poll for Git repository hash and set isOutdated when it changes Aug 10, 2023
@ghengeveld ghengeveld force-pushed the ghengeveld/ap-3369-add-concept-of-outdated-builds branch from a13e30d to d0267bf Compare August 10, 2023 14:24
@ghengeveld ghengeveld marked this pull request as draft August 10, 2023 15:05
Copy link
Member

@tmeasday tmeasday left a comment

Choose a reason for hiding this comment

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

Looking good.

Can we move the gitStateHash code to the CLI and pull it from there? I already do that (for the other git info) in this PR: https://github.com/chromaui/addon-visual-tests/pull/26/files

src/index.ts Outdated Show resolved Hide resolved
src/Panel.tsx Outdated Show resolved Hide resolved
@ghengeveld ghengeveld marked this pull request as ready for review August 15, 2023 15:59
Copy link
Member

@tmeasday tmeasday left a comment

Choose a reason for hiding this comment

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

Looks great! This looks like it includes some fixes for other issues too, make sure you close them too if so!

src/Panel.tsx Outdated Show resolved Hide resolved
@ghengeveld ghengeveld merged commit 4c6b7c5 into main Aug 16, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants