1
2
3
4
5
6
7
8
9
10 package org.eclipse.jgit.api;
11
12 import java.io.IOException;
13 import java.text.MessageFormat;
14 import java.util.Collection;
15
16 import org.eclipse.jgit.api.errors.GitAPIException;
17 import org.eclipse.jgit.api.errors.InvalidRefNameException;
18 import org.eclipse.jgit.api.errors.RefNotFoundException;
19 import org.eclipse.jgit.internal.JGitText;
20 import org.eclipse.jgit.lib.Constants;
21 import org.eclipse.jgit.lib.ReflogEntry;
22 import org.eclipse.jgit.lib.ReflogReader;
23 import org.eclipse.jgit.lib.Repository;
24
25
26
27
28
29
30
31
32 public class ReflogCommand extends GitCommand<Collection<ReflogEntry>> {
33
34 private String ref = Constants.HEAD;
35
36
37
38
39
40
41
42 public ReflogCommand(Repository repo) {
43 super(repo);
44 }
45
46
47
48
49
50
51
52
53
54 public ReflogCommand setRef(String ref) {
55 checkCallable();
56 this.ref = ref;
57 return this;
58 }
59
60
61
62
63
64
65 @Override
66 public Collection<ReflogEntry> call() throws GitAPIException,
67 InvalidRefNameException {
68 checkCallable();
69
70 try {
71 ReflogReader reader = repo.getReflogReader(ref);
72 if (reader == null)
73 throw new RefNotFoundException(MessageFormat.format(
74 JGitText.get().refNotResolved, ref));
75 return reader.getReverseEntries();
76 } catch (IOException e) {
77 throw new InvalidRefNameException(MessageFormat.format(
78 JGitText.get().cannotRead, ref), e);
79 }
80 }
81
82 }