Skip to content

Add git diff mode to CLI#1724

Merged
mtdowling merged 1 commit intomainfrom
add-git-diff-mode
Apr 7, 2023
Merged

Add git diff mode to CLI#1724
mtdowling merged 1 commit intomainfrom
add-git-diff-mode

Conversation

@mtdowling
Copy link
Copy Markdown
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
Copy Markdown
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 force-pushed the diff-project-mode branch from 9154017 to 98d5ff1 Compare April 6, 2023 17:34
@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 force-pushed the add-git-diff-mode branch from eb144e1 to 6bb1bd9 Compare April 6, 2023 23:40
@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