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

Add git diff mode to CLI #1724

Merged
merged 1 commit into from
Apr 7, 2023
Merged

Add git diff mode to CLI #1724

merged 1 commit into from
Apr 7, 2023

Conversation

mtdowling
Copy link
Member

This commit adds support for running Smithy diff using a "git" mode so that the current state of a project is compared against the previous state of a project. By default, the previous state is the last commit of the current branch:

smithy diff --mode git

You can compare against a differet commit using:

smithy diff --mode git --old HEAD~2
smithy diff --mode git --old main

The way this works it that git mode is a wrapper around project mode. Smithy will create a git worktree for a specific branch named __smithy-diff-worktree located at
"build/smithy/diff-worktree". Each time the command is run, the worktree is either created and pointed at the correct commit, or uses git reset --hard $COMMIT. When creating the worktree, we first call "git worktree prune" in case the worktree was previously created and deleted from a smithy clean operation.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mtdowling mtdowling requested a review from a team as a code owner April 6, 2023 00:02
Copy link
Contributor

@JordonPhillips JordonPhillips left a comment

Choose a reason for hiding this comment

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

Nice!

@mtdowling mtdowling changed the base branch from diff-project-mode to main April 6, 2023 17:55
@mtdowling mtdowling force-pushed the add-git-diff-mode branch 8 times, most recently from ea0b4c0 to eb144e1 Compare April 6, 2023 23:20
This commit adds support for running Smithy diff using a "git" mode
so that the current state of a project is compared against the
previous state of a project. By default, the previous state is the
last commit of the current branch:

```
smithy diff --mode git
```

You can compare against a differet commit using:

```
smithy diff --mode git --old HEAD~2
smithy diff --mode git --old main
```

The way this works it that `git` mode is a wrapper around
`project` mode. Smithy will create a git worktree for a specific
branch named `__smithy-diff-worktree` located at
"build/smithy/diff-worktree". Each time the command is run, the
worktree is either created and pointed at the correct commit, or
uses `git reset --hard $COMMIT`. When creating the worktree, we first
call "git worktree prune" in case the worktree was previously
created and deleted from a `smithy clean` operation.
@mtdowling mtdowling merged commit 4fc805c into main Apr 7, 2023
@mtdowling mtdowling deleted the add-git-diff-mode branch April 7, 2023 03:29
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