diff options
author | Eike Stepper | 2013-07-09 11:56:55 +0000 |
---|---|---|
committer | Eike Stepper | 2013-07-09 11:56:55 +0000 |
commit | f9ff45b05b2cfc0afc8f6c05bbcc2c7430ab5895 (patch) | |
tree | d8fc27637fd8d7c2dcf8dee18adff3b1ca2ce4ef /plugins/org.eclipse.emf.cdo.releng.gitbash | |
parent | 7519a7d6990ae10ea2f3af70b27b02f7dea7ed1e (diff) | |
download | cdo-f9ff45b05b2cfc0afc8f6c05bbcc2c7430ab5895.tar.gz cdo-f9ff45b05b2cfc0afc8f6c05bbcc2c7430ab5895.tar.xz cdo-f9ff45b05b2cfc0afc8f6c05bbcc2c7430ab5895.zip |
Add Git branch decorator
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.releng.gitbash')
-rw-r--r-- | plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/decorators/BranchDecorator.java | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/decorators/BranchDecorator.java b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/decorators/BranchDecorator.java index e16c09583f..2ea42134e2 100644 --- a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/decorators/BranchDecorator.java +++ b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/decorators/BranchDecorator.java @@ -2,11 +2,14 @@ package org.eclipse.emf.cdo.releng.gitbash.decorators; import org.eclipse.jface.viewers.ILabelDecorator; import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jgit.lib.BranchTrackingStatus; import org.eclipse.jgit.lib.ConfigConstants; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.StoredConfig; import org.eclipse.swt.graphics.Image; +import java.io.IOException; + @SuppressWarnings("restriction") public class BranchDecorator implements ILabelDecorator { @@ -75,7 +78,8 @@ public class BranchDecorator implements ILabelDecorator private String getDecoration(org.eclipse.egit.ui.internal.repository.tree.RefNode node) { String branchName = Repository.shortenRefName(node.getObject().getName()); - StoredConfig config = node.getRepository().getConfig(); + Repository repository = node.getRepository(); + StoredConfig config = repository.getConfig(); String branch = config.getString(ConfigConstants.CONFIG_BRANCH_SECTION, branchName, ConfigConstants.CONFIG_KEY_MERGE); @@ -94,7 +98,22 @@ public class BranchDecorator implements ILabelDecorator } String prefix = ".".equals(remote) ? "" : remote + "/"; - return (rebaseFlag ? "REBASE" : "MERGE") + ": " + prefix + branch; + String result = (rebaseFlag ? "REBASE" : "MERGE") + ": " + prefix + branch; + + try + { + BranchTrackingStatus trackingStatus = BranchTrackingStatus.of(repository, branchName); + if (trackingStatus != null && (trackingStatus.getAheadCount() != 0 || trackingStatus.getBehindCount() != 0)) + { + result += " " + org.eclipse.egit.ui.internal.GitLabelProvider.formatBranchTrackingStatus(trackingStatus); + } + } + catch (IOException ex) + { + //$FALL-THROUGH$ + } + + return result; } return null; |