mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
git: cleanup: convert GitBranchPair to a kotlin dataclass and rename properties to more clear names
GitOrigin-RevId: 4433c399640b52f2637e6692d75ecd7c9c2d482b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e759aaf1ae
commit
95a7c1238f
@@ -13,35 +13,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package git4idea.branch;
|
||||
package git4idea.branch
|
||||
|
||||
import git4idea.GitLocalBranch;
|
||||
import git4idea.GitRemoteBranch;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import git4idea.GitLocalBranch
|
||||
import git4idea.GitRemoteBranch
|
||||
|
||||
/**
|
||||
* Holder for Git branch and the branch it is "connected" with. It is tracked branch or so called "matched" branch.
|
||||
*
|
||||
* @author Kirill Likhodedov
|
||||
*/
|
||||
public class GitBranchPair {
|
||||
private @NotNull final GitLocalBranch myBranch;
|
||||
private @Nullable final GitRemoteBranch myDestBranch;
|
||||
|
||||
public GitBranchPair(@NotNull GitLocalBranch branch, @Nullable GitRemoteBranch destination) {
|
||||
myBranch = branch;
|
||||
myDestBranch = destination;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public GitLocalBranch getBranch() {
|
||||
return myBranch;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GitRemoteBranch getDest() {
|
||||
return myDestBranch;
|
||||
}
|
||||
|
||||
}
|
||||
data class GitBranchPair(val source: GitLocalBranch, val target: GitRemoteBranch?)
|
||||
|
||||
@@ -68,7 +68,7 @@ public class GitMergeUpdater extends GitUpdater {
|
||||
String originalText = myProgressIndicator.getText();
|
||||
myProgressIndicator.setText("Merging" + GitUtil.mention(myRepository) + "...");
|
||||
try {
|
||||
GitCommandResult result = myGit.merge(myRepository, assertNotNull(myBranchPair.getDest()).getName(),
|
||||
GitCommandResult result = myGit.merge(myRepository, assertNotNull(myBranchPair.getTarget()).getName(),
|
||||
asList("--no-stat", "-v"), mergeLineListener, untrackedFilesDetector,
|
||||
GitStandardProgressAnalyzer.createListener(myProgressIndicator));
|
||||
myProgressIndicator.setText(originalText);
|
||||
@@ -134,8 +134,8 @@ public class GitMergeUpdater extends GitUpdater {
|
||||
}
|
||||
|
||||
// git log --name-status master..origin/master
|
||||
String currentBranch = myBranchPair.getBranch().getName();
|
||||
String remoteBranch = myBranchPair.getDest().getName();
|
||||
String currentBranch = myBranchPair.getSource().getName();
|
||||
String remoteBranch = myBranchPair.getTarget().getName();
|
||||
try {
|
||||
GitRepository repository = GitUtil.getRepositoryManager(myProject).getRepositoryForRoot(myRoot);
|
||||
if (repository == null) {
|
||||
|
||||
@@ -74,9 +74,9 @@ public class GitRebaseUpdater extends GitUpdater {
|
||||
|
||||
@NotNull
|
||||
private String getRemoteBranchToMerge() {
|
||||
GitBranch dest = myBranchPair.getDest();
|
||||
GitBranch dest = myBranchPair.getTarget();
|
||||
LOG.assertTrue(dest != null, String.format("Destination branch is null for source branch %s in %s",
|
||||
myBranchPair.getBranch().getName(), myRoot));
|
||||
myBranchPair.getSource().getName(), myRoot));
|
||||
return dest.getName();
|
||||
}
|
||||
|
||||
|
||||
@@ -266,8 +266,8 @@ public class GitUpdateProcess {
|
||||
return ContainerUtil.mapNotNull(updaters.keySet(), repo -> {
|
||||
GitUpdater updater = updaters.get(repo);
|
||||
if (updater instanceof GitRebaseUpdater) {
|
||||
String currentRef = ((GitRebaseUpdater)updater).getSourceAndTarget().getBranch().getFullName();
|
||||
String baseRef = assertNotNull(((GitRebaseUpdater)updater).getSourceAndTarget().getDest()).getFullName();
|
||||
String currentRef = ((GitRebaseUpdater)updater).getSourceAndTarget().getSource().getFullName();
|
||||
String baseRef = assertNotNull(((GitRebaseUpdater)updater).getSourceAndTarget().getTarget()).getFullName();
|
||||
return GitRebaseOverMergeProblem.hasProblem(myProject, repo.getRoot(), baseRef, currentRef) ? repo : null;
|
||||
}
|
||||
return null;
|
||||
@@ -328,8 +328,8 @@ public class GitUpdateProcess {
|
||||
private Map<GitRepository, Hash> calcPublishedTipPositions(@NotNull Map<GitRepository, GitBranchPair> trackedBranches) {
|
||||
Map<GitRepository, Hash> result = new LinkedHashMap<>();
|
||||
for (GitRepository repository : trackedBranches.keySet()) {
|
||||
GitLocalBranch localBranch = trackedBranches.get(repository).getBranch();
|
||||
GitRemoteBranch trackedBranch = trackedBranches.get(repository).getDest();
|
||||
GitLocalBranch localBranch = trackedBranches.get(repository).getSource();
|
||||
GitRemoteBranch trackedBranch = trackedBranches.get(repository).getTarget();
|
||||
if (trackedBranch != null) {
|
||||
Hash mergeBase = getMergeBase(repository.getRoot(), localBranch.getFullName(), trackedBranch.getFullName());
|
||||
if (mergeBase != null) {
|
||||
|
||||
@@ -166,7 +166,7 @@ public abstract class GitUpdater {
|
||||
* @return true if update is needed, false otherwise.
|
||||
*/
|
||||
public boolean isUpdateNeeded(@NotNull GitBranchPair branchPair) throws VcsException {
|
||||
GitBranch dest = branchPair.getDest();
|
||||
GitBranch dest = branchPair.getTarget();
|
||||
assert dest != null;
|
||||
String remoteBranch = dest.getName();
|
||||
if (!hasRemoteChanges(remoteBranch)) {
|
||||
|
||||
Reference in New Issue
Block a user