feat: Allow checking out scratch area on target revisions #1278
+180
−14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #813 (@noemifrisina for comment on current implementation while I work on tests).
Allows configuring a target revision for a repository checked out in the scratch area.
I think I have overcomplicated the actual use case, but hopefully this diagram helps explain: checks out an existing branch of the desired name (if possible), else checks out the existing tag (if possible) and creates a branch of the name to track changes.
flowchart TD Start{Repo already exists in scratch?} --> |No| Clone[Clone default branch of repo from remote] Start --> |Yes| Connect[Use existing repo on current branch] Clone --> Configured{Target revision configured?} Connect --> Configured Configured --> |No| End Configured --> |Yes| Fetch[Fetch configured remote] Fetch --> Branch{Branch of name exists?} Branch --> |Yes| Checkout[Check out branch] Branch --> |No| Exists{Tag configured?} Exists --> |Yes| Tag{Tag of name exists?} Exists --> |No| Except Tag --> |Yes| Create[Check out tag] Create --> CB[Create branch of name] Tag --> |No| Except Checkout --> ShouldPull{.pull?} CB --> Checkout ShouldPull --> |No| End ShouldPull --> |Yes| pull pull --> Endexample:
Checks out dodal on 1.65 and creates a
devbranch to track it, if a branch calleddevdoes not exist locally