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

feat(utils): add git helper #469

Merged
merged 43 commits into from
Feb 26, 2024
Merged

feat(utils): add git helper #469

merged 43 commits into from
Feb 26, 2024

Conversation

BioPhoton
Copy link
Collaborator

@BioPhoton BioPhoton commented Feb 5, 2024

This PR includes utility functions related to git logic use in the future history command.

Methods included:

  • getCurrentBranchOrTag - The history command needs to end in the same branch where it started. This method is called before we start walking the repo history to save the "initial" branch
  • statusIsClean - To safely check out a branch the status needs to be clean
  • guardAgainstLocalChanges - the command should throw if the git status is not clean
  • safeCheckout - as there might be some files generated while walking the history we need to do the following:
    • warn the user that the status is not clean (initial checkout)
    • drop all created changes after each run

partially resolves #216

@BioPhoton BioPhoton marked this pull request as ready for review February 5, 2024 21:17
Copy link
Collaborator

@matejchalk matejchalk left a comment

Choose a reason for hiding this comment

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

Sorry, but requiring a clean repository state in order to run integration tests is a hard no from a DX perspective 🙅‍♂️ Either make the tests the tests more robust, or don't test it.

packages/utils/src/lib/git.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/git.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/git.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/git.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/git.integration.test.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/git.integration.test.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/git.integration.test.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/git.integration.test.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/git.integration.test.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/git.integration.test.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/git.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/git.ts Outdated Show resolved Hide resolved
testing-utils/src/index.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/git.integration.test.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/git.integration.test.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/git.integration.test.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/git.integration.test.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/git.integration.test.ts Outdated Show resolved Hide resolved
BioPhoton and others added 15 commits February 6, 2024 13:02
Co-authored-by: Matěj Chalk <34691111+matejchalk@users.noreply.github.com>
Co-authored-by: Matěj Chalk <34691111+matejchalk@users.noreply.github.com>
Co-authored-by: Matěj Chalk <34691111+matejchalk@users.noreply.github.com>
Co-authored-by: Matěj Chalk <34691111+matejchalk@users.noreply.github.com>
Co-authored-by: Matěj Chalk <34691111+matejchalk@users.noreply.github.com>
Co-authored-by: Katka Pilátová <katerina.pilatova@flowup.cz>
Co-authored-by: Katka Pilátová <katerina.pilatova@flowup.cz>
Co-authored-by: Katka Pilátová <katerina.pilatova@flowup.cz>
Co-authored-by: Katka Pilátová <katerina.pilatova@flowup.cz>
Co-authored-by: Katka Pilátová <katerina.pilatova@flowup.cz>
@BioPhoton BioPhoton mentioned this pull request Feb 6, 2024
matejchalk
matejchalk previously approved these changes Feb 19, 2024
Copy link
Collaborator

@Tlacenka Tlacenka left a comment

Choose a reason for hiding this comment

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

Not sure which methods are needed for the history command. A brief intro in the PR description explaining the goal would be helpful. 🙏
Currently, I can only check the tests, not if the list of methods is sufficient.

Test feedback below.

packages/utils/src/lib/git.integration.test.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/git.integration.test.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/git.integration.test.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/git.integration.test.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/git.ts Outdated Show resolved Hide resolved
matejchalk
matejchalk previously approved these changes Feb 20, 2024
packages/utils/src/lib/git.integration.test.ts Outdated Show resolved Hide resolved
packages/utils/src/lib/git.ts Outdated Show resolved Hide resolved
Co-authored-by: Katka Pilátová <katerina.pilatova@flowup.cz>
Copy link

nx-cloud bot commented Feb 23, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 1a4206d. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 4 targets

Sent with 💌 from NxCloud.

Copy link
Collaborator

@Tlacenka Tlacenka 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! 🧪

Added one comment but can be done in a separate PR.

packages/utils/src/lib/git.ts Show resolved Hide resolved
@BioPhoton BioPhoton merged commit d927a61 into main Feb 26, 2024
20 checks passed
@BioPhoton BioPhoton deleted the add-git-helper branch February 26, 2024 23:23
@BioPhoton BioPhoton mentioned this pull request Mar 5, 2024
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

History command
3 participants