Skip to content

Commit

Permalink
Fix slide in suggestion on the repo that is not selected at the moment (
Browse files Browse the repository at this point in the history
closes #1529)
  • Loading branch information
mkondratek committed Feb 13, 2023
1 parent d1a5142 commit fd3f50a
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Improved the repository selection combobox so that modules are now searchable.
- Added a field to provide/edit a custom annotation in the Slide In dialog.
- Added Compare With Parent action to the context menu.
- Fixed an issue with Slide In Unmanaged Branch Notification for a branch from a git repository that is not selected.

## v3.5.1
- Improve stability of traverse and slide-out/slide-in actions.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.virtuslab.gitmachete.backend.api;

import java.nio.file.Path;

import io.vavr.collection.List;
import io.vavr.collection.Set;
import lombok.Data;
Expand All @@ -13,6 +15,8 @@
* Each {@code get...} method is guaranteed to return the same value each time it's called on a given object.
*/
public interface IGitMacheteRepositorySnapshot {
Path getMainGitDirectoryPath();

BranchLayout getBranchLayout();

List<IRootManagedBranchSnapshot> getRootBranches();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.virtuslab.gitmachete.backend.api;

import java.nio.file.Path;

import io.vavr.collection.List;
import io.vavr.collection.Set;
import io.vavr.collection.TreeSet;
Expand All @@ -18,6 +20,11 @@ public static IGitMacheteRepositorySnapshot getInstance() {
return instance;
}

@Override
public Path getMainGitDirectoryPath() {
return Path.of("");
}

@Override
public BranchLayout getBranchLayout() {
return new BranchLayout(List.empty());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.virtuslab.gitmachete.backend.impl;

import java.nio.file.Path;

import io.vavr.collection.LinkedHashMap;
import io.vavr.collection.List;
import io.vavr.collection.Set;
Expand All @@ -19,6 +21,9 @@
@RequiredArgsConstructor
public class GitMacheteRepositorySnapshot implements IGitMacheteRepositorySnapshot {

@Getter
private final Path mainGitDirectoryPath;

@Getter
private final List<IRootManagedBranchSnapshot> rootBranches;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static io.vavr.API.Case;
import static io.vavr.API.Match;

import java.nio.file.Path;
import java.time.Instant;

import io.vavr.Tuple;
Expand Down Expand Up @@ -57,6 +58,7 @@ public class CreateGitMacheteRepositoryAux extends Aux {
private final PreRebaseHookExecutor preRebaseHookExecutor;
private final List<String> remoteNames;
private final java.util.Set<String> createdBranches = new java.util.HashSet<>();
private final Path mainGitDirectoryPath;

public CreateGitMacheteRepositoryAux(
IGitCoreRepository gitCoreRepository,
Expand All @@ -67,6 +69,7 @@ public CreateGitMacheteRepositoryAux(
this.statusHookExecutor = statusHookExecutor;
this.preRebaseHookExecutor = preRebaseHookExecutor;
this.remoteNames = gitCoreRepository.deriveAllRemoteNames();
this.mainGitDirectoryPath = gitCoreRepository.getMainGitDirectoryPath();
}

@UIThreadUnsafe
Expand Down Expand Up @@ -105,7 +108,8 @@ public IGitMacheteRepositorySnapshot createSnapshot(BranchLayout branchLayout) t

val operationsBaseBranchName = deriveOngoingOperationsBaseBranchName(ongoingOperationType);

return new GitMacheteRepositorySnapshot(List.narrow(rootBranches), branchLayout, currentBranchIfManaged,
return new GitMacheteRepositorySnapshot(mainGitDirectoryPath, List.narrow(rootBranches), branchLayout,
currentBranchIfManaged,
managedBranchByName, duplicatedBranchNames, skippedBranchNames, preRebaseHookExecutor,
new IGitMacheteRepositorySnapshot.OngoingRepositoryOperation(ongoingOperationType, operationsBaseBranchName));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.virtuslab.gitmachete.frontend.ui.impl.table;

import java.nio.file.Path;
import java.time.Instant;

import io.vavr.NotImplementedError;
Expand Down Expand Up @@ -91,6 +92,11 @@ static RelationToRemote getRelationOfSTRS(SyncToRemoteStatus syncToRemoteStatus)
return RelationToRemote.of(syncToRemoteStatus, "origin");
}

@Override
public Path getMainGitDirectoryPath() {
return Path.of("dummy");
}

@Override
public BranchLayout getBranchLayout() {
throw new NotImplementedError();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,10 @@ private void trackCurrentBranchChange(GitRepository repository) {
if (unmanagedBranchNotification != null) {
unmanagedBranchNotification.expire();
}
if (gitMacheteRepositorySnapshot != null) {
val entry = gitMacheteRepositorySnapshot.getBranchLayout().getEntryByName(repositoryCurrentBranchName);
val snapshot = gitMacheteRepositorySnapshot;
val mainGitDirectory = GitVfsUtils.getMainGitDirectory(repository);
if (snapshot != null && snapshot.getMainGitDirectoryPath().equals(mainGitDirectory)) {
val entry = snapshot.getBranchLayout().getEntryByName(repositoryCurrentBranchName);
if (entry == null) {
inferParentForUnmanagedBranchNotificationAndNotify(repositoryCurrentBranchName);
}
Expand Down

0 comments on commit fd3f50a

Please sign in to comment.