Fix incorrect editor updates with changes from diff-viewer
[egit.git] / org.eclipse.egit.core / src / org / eclipse / egit / core / internal / Utils.java
blobe8df4292e40d81e6ef8da859ab9445ac0a9f332e
1 /*******************************************************************************
2 * Copyright (C) 2010, Jens Baumgart <jens.baumgart@sap.com>
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
9 package org.eclipse.egit.core.internal;
11 import java.io.File;
13 import org.eclipse.jgit.lib.ObjectId;
14 import org.eclipse.jgit.lib.Repository;
16 /**
17 * Utility class
20 public class Utils {
22 /**
23 * @param repository
24 * @return display name of the repository
26 public static String getRepositoryName(Repository repository) {
27 String repositoryName;
28 File gitDir = repository.getDirectory();
29 if (gitDir != null)
30 repositoryName = repository.getDirectory().getParentFile()
31 .getName();
32 else
33 repositoryName = ""; //$NON-NLS-1$
34 return repositoryName;
37 /**
38 * @param id
39 * @return a shortened ObjectId (first 6 digits)
41 public static String getShortObjectId(ObjectId id) {
42 return id.getName().substring(0, 6);