git4idea: Added support for checking locally modified files
[fedora-idea.git] / plugins / git4idea / src / git4idea / GitTag.java
blobfc55715b84e56fad69eec3d4ed051e4aeafd56e2
1 /*
2 * Copyright 2000-2008 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package git4idea;
18 import com.intellij.openapi.project.Project;
19 import com.intellij.openapi.vcs.VcsException;
20 import com.intellij.openapi.vfs.VirtualFile;
21 import git4idea.commands.GitHandler;
22 import git4idea.commands.GitSimpleHandler;
23 import org.jetbrains.annotations.NonNls;
24 import org.jetbrains.annotations.NotNull;
26 import java.util.ArrayList;
27 import java.util.Collection;
29 /**
30 * The tag reference object
32 public class GitTag extends GitReference {
33 /**
34 * Prefix for tags ({@value})
36 @NonNls public static final String REFS_TAGS_PREFIX = "refs/tags/";
38 /**
39 * The constructor
41 * @param name the used name
43 public GitTag(@NotNull String name) {
44 super(name);
47 /**
48 * {@inheritDoc}
50 @NotNull
51 public String getFullName() {
52 return REFS_TAGS_PREFIX + myName;
55 /**
56 * List tags for the git root
58 * @param project the context
59 * @param root the git root
60 * @param tags the tag list
61 * @throws VcsException if there is a problem with running git
63 public static void listAsStrings(final Project project, final VirtualFile root, final Collection<String> tags) throws VcsException {
64 GitSimpleHandler handler = new GitSimpleHandler(project, root, GitHandler.TAG);
65 handler.setNoSSH(true);
66 handler.setSilent(true);
67 handler.addParameters("-l");
68 for (String line : handler.run().split("\n")) {
69 if (line.length() == 0) {
70 continue;
72 tags.add(line);
76 /**
77 * List tags for the git root
79 * @param project the context
80 * @param root the git root
81 * @param tags the tag list
82 * @throws VcsException if there is a problem with running git
84 public static void list(final Project project, final VirtualFile root, final Collection<? super GitTag> tags) throws VcsException {
85 ArrayList<String> temp = new ArrayList<String>();
86 listAsStrings(project, root, temp);
87 for (String t : temp) {
88 tags.add(new GitTag(t));