blob: e9ea8c7b4f428241151956586b6a5dd409395446 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/*******************************************************************************
* Copyright (C) 2015, Max Hohenegger <eclipse@hohenegger.eu>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package org.eclipse.egit.gitflow.op;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.egit.gitflow.GitFlowRepository;
import org.eclipse.egit.gitflow.WrongGitFlowStateException;
import org.eclipse.egit.gitflow.internal.CoreText;
/**
* Common logic for feature branch operations.
*/
abstract public class AbstractFeatureOperation extends GitFlowOperation {
/** */
protected String featureName;
/**
* @param repository
* @param featureName
*/
public AbstractFeatureOperation(GitFlowRepository repository,
String featureName) {
super(repository);
this.featureName = featureName;
}
/**
* @param repository
* @return current feature branch name
* @throws WrongGitFlowStateException
* @throws CoreException
* @throws IOException
*/
protected static String getFeatureName(GitFlowRepository repository)
throws WrongGitFlowStateException, CoreException, IOException {
if (!repository.isFeature()) {
throw new WrongGitFlowStateException(
CoreText.AbstractFeatureOperation_notOnAFeautreBranch);
}
String currentBranch = repository.getRepository().getBranch();
return currentBranch.substring(repository.getConfig()
.getFeaturePrefix().length());
}
}
|