3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core;
23 |
24 | import java.io.Serializable;
25 | import java.util.Comparator;
26 |
27 | import org.eclipse.jgit.lib.PersonIdent;
28 |
29 | /**
30 | * {@link PersonIdent} comparator that compares the name and email address.
31 | *
32 | * This class compares {@link PersonIdent#getName()} values first and if they
33 | * are identical then it will compare the {@link PersonIdent#getEmailAddress()}
34 | * values next.
35 | */
36 | public class PersonComparator implements Comparator, Serializable {
37 |
38 | /** */
39 | private static final long serialVersionUID = -14341068273148025L;
40 |
41 | /**
42 | * Instance
43 | */
44 | public static final PersonComparator INSTANCE = new PersonComparator();
45 |
46 | /**
47 | * Check if the two given {@link PersonIdent} objects are equal according to
48 | * the semantics of {@link #compare(PersonIdent, PersonIdent)}.
49 | *
50 | * @param p1
51 | * @param p2
52 | * @return true if equal, false otherwise
53 | */
54 | public boolean equals(final PersonIdent p1, final PersonIdent p2) {
55 | return compare(p1, p2) == 0;
56 | }
57 |
58 | public int compare(final PersonIdent p1, final PersonIdent p2) {
59 | int compare = p1.getName().compareTo(p2.getName());
60 | if (compare == 0)
61 | compare = p1.getEmailAddress().compareTo(p2.getEmailAddress());
62 | return compare;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/AllCommitFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.io.IOException;
25 |
26 | import org.eclipse.jgit.revwalk.RevCommit;
27 | import org.eclipse.jgit.revwalk.RevWalk;
28 | import org.eclipse.jgit.revwalk.filter.RevFilter;
29 |
30 | /**
31 | * Composite filter that will always include every commit but still calls the
32 | * {@link RevFilter#include(RevWalk, RevCommit)} method on each filter that has
33 | * been added to this filter.
34 | *
35 | * This filter is most often used when you want to ensure that a collection of
36 | * filters are each always called on every commit in a {@link RevWalk}.
37 | */
38 | public class AllCommitFilter extends CompositeCommitFilter {
39 |
40 | /**
41 | * Create an all commit filter with given child filters
42 | *
43 | * @param filters
44 | */
45 | public AllCommitFilter(final RevFilter... filters) {
46 | super(filters);
47 | }
48 |
49 | @Override
50 | public boolean include(final RevWalk walker, final RevCommit commit)
51 | throws IOException {
52 | final int length = filters.length;
53 | for (int i = 0; i < length; i++)
54 | filters[i].include(walker, commit);
55 | return true;
56 | }
57 |
58 | @Override
59 | public RevFilter clone() {
60 | return new AllCommitFilter(cloneFilters());
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/AllDiffEditFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.util.Collection;
25 |
26 | import org.eclipse.jgit.diff.DiffEntry;
27 | import org.eclipse.jgit.diff.Edit;
28 | import org.eclipse.jgit.revwalk.RevCommit;
29 | import org.eclipse.jgit.revwalk.filter.RevFilter;
30 |
31 | /**
32 | * Parent filter that invokes
33 | * {@link #include(org.eclipse.jgit.revwalk.RevCommit, java.util.Collection)} on
34 | * all child filters ignoring the return value
35 | */
36 | public class AllDiffEditFilter extends CompositeDiffEditFilter {
37 |
38 | /**
39 | * Create all diff edit filter
40 | *
41 | * @param detectRenames
42 | * @param filters
43 | */
44 | public AllDiffEditFilter(final boolean detectRenames,
45 | final CommitDiffEditFilter... filters) {
46 | super(detectRenames, filters);
47 | }
48 |
49 | /**
50 | * Create all diff edit filter
51 | *
52 | * @param filters
53 | */
54 | public AllDiffEditFilter(final CommitDiffEditFilter... filters) {
55 | this(false, filters);
56 | }
57 |
58 | @Override
59 | protected boolean include(final RevCommit commit, final DiffEntry diff,
60 | final Collection edits) {
61 | final int length = filters.length;
62 | for (int i = 0; i < length; i++)
63 | filters[i].include(commit, diff, edits);
64 | return true;
65 | }
66 |
67 | @Override
68 | public RevFilter clone() {
69 | return new AllDiffFilter(detectRenames, cloneFilters());
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/AllDiffFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.io.IOException;
25 | import java.util.Collection;
26 |
27 | import org.eclipse.jgit.diff.DiffEntry;
28 | import org.eclipse.jgit.revwalk.RevCommit;
29 | import org.eclipse.jgit.revwalk.RevWalk;
30 | import org.eclipse.jgit.revwalk.filter.RevFilter;
31 |
32 | /**
33 | * Parent filter that invokes {@link #include(RevWalk, RevCommit, Collection)}
34 | * on all child filters ignoring the return value
35 | */
36 | public class AllDiffFilter extends CompositeDiffFilter {
37 |
38 | /**
39 | * Create all diff filter
40 | *
41 | * @param detectRenames
42 | * @param filters
43 | */
44 | public AllDiffFilter(final boolean detectRenames,
45 | final CommitDiffFilter... filters) {
46 | super(detectRenames, filters);
47 | }
48 |
49 | /**
50 | * Create all diff filter
51 | *
52 | * @param filters
53 | */
54 | public AllDiffFilter(final CommitDiffFilter... filters) {
55 | this(false, filters);
56 | }
57 |
58 | @Override
59 | public boolean include(final RevWalk walker, final RevCommit commit,
60 | final Collection diffs) throws IOException {
61 | final int length = filters.length;
62 | for (int i = 0; i < length; i++)
63 | filters[i].include(walker, commit, diffs);
64 | return true;
65 | }
66 |
67 | @Override
68 | public RevFilter clone() {
69 | return new AllDiffFilter(detectRenames, cloneFilters());
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/AndCommitFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.io.IOException;
25 |
26 | import org.eclipse.jgit.revwalk.RevCommit;
27 | import org.eclipse.jgit.revwalk.RevWalk;
28 | import org.eclipse.jgit.revwalk.filter.RevFilter;
29 |
30 | /**
31 | * Composite filter that only includes commits that are included by every child
32 | * filter that has been added to this parent filter.
33 | */
34 | public class AndCommitFilter extends CompositeCommitFilter {
35 |
36 | /**
37 | * Create an empty and commit filter
38 | */
39 | public AndCommitFilter() {
40 | super();
41 | }
42 |
43 | /**
44 | * Create and commit filter with given child filters
45 | *
46 | * @param filters
47 | */
48 | public AndCommitFilter(final RevFilter... filters) {
49 | super(filters);
50 | }
51 |
52 | @Override
53 | public boolean include(final RevWalk walker, final RevCommit commit)
54 | throws IOException {
55 | final int length = filters.length;
56 | for (int i = 0; i < length; i++)
57 | if (!filters[i].include(walker, commit))
58 | return include(false);
59 | return true;
60 | }
61 |
62 | @Override
63 | public RevFilter clone() {
64 | return new AndCommitFilter(cloneFilters());
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/AuthorDateFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.util.Date;
25 |
26 | import org.eclipse.jgit.revwalk.RevCommit;
27 | import org.eclipse.jgit.revwalk.filter.RevFilter;
28 |
29 | /**
30 | * Filter that includes commits until an authored date is encountered that
31 | * occurred before the configured date.
32 | */
33 | public class AuthorDateFilter extends DateFilter {
34 |
35 | /**
36 | * Create an author date filter for the given date
37 | *
38 | * @param date
39 | */
40 | public AuthorDateFilter(final Date date) {
41 | super(date);
42 | }
43 |
44 | /**
45 | * Create an author date filter for the given time
46 | *
47 | * @param time
48 | */
49 | public AuthorDateFilter(final long time) {
50 | super(time);
51 | }
52 |
53 | @Override
54 | protected Date getDate(final RevCommit commit) {
55 | return getWhen(commit.getAuthorIdent());
56 | }
57 |
58 | @Override
59 | public RevFilter clone() {
60 | return new AuthorDateFilter(time);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/AuthorFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.io.IOException;
25 |
26 | import org.eclipse.jgit.lib.PersonIdent;
27 | import org.eclipse.jgit.revwalk.RevCommit;
28 | import org.eclipse.jgit.revwalk.RevWalk;
29 | import org.eclipse.jgit.revwalk.filter.RevFilter;
30 |
31 | /**
32 | * Person filter that includes commits where a {@link PersonIdent} matches the
33 | * name and e-mail address of a commit's author.
34 | */
35 | public class AuthorFilter extends PersonFilter {
36 |
37 | /**
38 | * Create an author filter for the given person
39 | *
40 | * @param person
41 | */
42 | public AuthorFilter(final PersonIdent person) {
43 | super(person);
44 | }
45 |
46 | /**
47 | * Create an author filter for the given name and e-mail address
48 | *
49 | * @param name
50 | * @param email
51 | */
52 | public AuthorFilter(final String name, final String email) {
53 | super(name, email);
54 | }
55 |
56 | @Override
57 | public boolean include(final RevWalk walker, final RevCommit commit)
58 | throws IOException {
59 | return match(commit.getAuthorIdent()) ? true : include(false);
60 | }
61 |
62 | @Override
63 | public RevFilter clone() {
64 | return new AuthorFilter(name, email);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/AuthorSetFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import org.eclipse.jgit.lib.PersonIdent;
25 | import org.eclipse.jgit.revwalk.RevCommit;
26 | import org.eclipse.jgit.revwalk.filter.RevFilter;
27 |
28 | /**
29 | * Filter that collects author {@link PersonIdent} objects for each commit
30 | * visited.
31 | */
32 | public class AuthorSetFilter extends PersonSetFilter {
33 |
34 | @Override
35 | protected PersonIdent getPerson(final RevCommit commit) {
36 | return commit.getAuthorIdent();
37 | }
38 |
39 | @Override
40 | public RevFilter clone() {
41 | return new AuthorSetFilter();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/BugFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import static java.util.regex.Pattern.MULTILINE;
25 |
26 | import org.eclipse.jgit.revwalk.filter.RevFilter;
27 |
28 | /**
29 | * Filter that matches bugs referenced in commit messages.
30 | */
31 | public class BugFilter extends CommitMessageFindFilter {
32 |
33 | /**
34 | * BUG_REGEX
35 | */
36 | public static final String BUG_REGEX = "^Bug: (\\w+)$";
37 |
38 | /**
39 | * Create bug filter
40 | */
41 | public BugFilter() {
42 | super(BUG_REGEX, MULTILINE);
43 | }
44 |
45 | @Override
46 | public RevFilter clone() {
47 | return new BugFilter();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/BugSetFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import static java.util.regex.Pattern.MULTILINE;
25 | import static org.gitective.core.filter.commit.BugFilter.BUG_REGEX;
26 |
27 | import java.io.IOException;
28 | import java.util.HashSet;
29 | import java.util.Set;
30 |
31 | import org.eclipse.jgit.revwalk.RevCommit;
32 | import org.eclipse.jgit.revwalk.RevWalk;
33 | import org.eclipse.jgit.revwalk.filter.RevFilter;
34 |
35 | /**
36 | * Filter that collects all bugs referenced in commit messages.
37 | */
38 | public class BugSetFilter extends CommitMessageFindFilter {
39 |
40 | private final Set bugs = new HashSet();
41 |
42 | /**
43 | * Create new bug set filter
44 | */
45 | public BugSetFilter() {
46 | super(BUG_REGEX, MULTILINE);
47 | }
48 |
49 | /**
50 | * Get the bugs ids collected
51 | *
52 | * @return non-null but possibly empty set of bug ids
53 | */
54 | public Set getBugs() {
55 | return bugs;
56 | }
57 |
58 | @Override
59 | public boolean include(final RevWalk walker, final RevCommit commit)
60 | throws IOException {
61 | matcher.reset(getText(commit));
62 | while (matcher.find())
63 | bugs.add(matcher.group(1));
64 | return true;
65 | }
66 |
67 | @Override
68 | public RevFilter clone() {
69 | return new BugSetFilter();
70 | }
71 |
72 | @Override
73 | public CommitFilter reset() {
74 | bugs.clear();
75 | return super.reset();
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/ChangeIdFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import static java.util.regex.Pattern.MULTILINE;
25 |
26 | import org.eclipse.jgit.revwalk.filter.RevFilter;
27 |
28 | /**
29 | * Commit message pattern filter that includes commits that contain a valid
30 | * Gerrit {@link #CHANGE_ID_REGEX}.
31 | */
32 | public class ChangeIdFilter extends CommitMessageFindFilter {
33 |
34 | /**
35 | * CHANGE_ID_REGEX
36 | */
37 | public static final String CHANGE_ID_REGEX = "Change-Id: I[0-9a-f]{40}";
38 |
39 | /**
40 | * Create change id filter
41 | */
42 | public ChangeIdFilter() {
43 | super(CHANGE_ID_REGEX, MULTILINE);
44 | }
45 |
46 | @Override
47 | public RevFilter clone() {
48 | return new ChangeIdFilter();
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/CommitCountFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.io.IOException;
25 |
26 | import org.eclipse.jgit.revwalk.RevCommit;
27 | import org.eclipse.jgit.revwalk.RevWalk;
28 | import org.eclipse.jgit.revwalk.filter.RevFilter;
29 |
30 | /**
31 | * Commit filter that increments a counter on each commit visited.
32 | */
33 | public class CommitCountFilter extends CommitFilter {
34 |
35 | private long count;
36 |
37 | @Override
38 | public boolean include(final RevWalk walker, final RevCommit commit)
39 | throws IOException {
40 | count++;
41 | return true;
42 | }
43 |
44 | /**
45 | * Get number of commits visited
46 | *
47 | * @return count
48 | */
49 | public long getCount() {
50 | return count;
51 | }
52 |
53 | @Override
54 | public CommitFilter reset() {
55 | count = 0L;
56 | return super.reset();
57 | }
58 |
59 | @Override
60 | public RevFilter clone() {
61 | return new CommitCountFilter();
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/CommitFieldLengthFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.util.HashSet;
25 | import java.util.Iterator;
26 | import java.util.Set;
27 |
28 | import org.eclipse.jgit.revwalk.RevCommit;
29 |
30 | /**
31 | * Base filter that tracks commits that have a field with the same length
32 | */
33 | public abstract class CommitFieldLengthFilter extends CommitFilter implements
34 | Iterable {
35 |
36 | /**
37 | * Commits tracked
38 | */
39 | protected final Set commits = new HashSet();
40 |
41 | /**
42 | * Field length
43 | */
44 | protected int length = -1;
45 |
46 | /**
47 | * Include commit with given field length
48 | *
49 | * @param fieldLength
50 | * @param commit
51 | */
52 | protected void include(int fieldLength, RevCommit commit) {
53 | if (fieldLength != length) {
54 | commits.clear();
55 | commits.add(commit);
56 | length = fieldLength;
57 | } else
58 | commits.add(commit);
59 | }
60 |
61 | @Override
62 | public CommitFilter reset() {
63 | commits.clear();
64 | length = -1;
65 | return super.reset();
66 | }
67 |
68 | public Iterator iterator() {
69 | return commits.iterator();
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/CommitLimitFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.io.IOException;
25 |
26 | import org.eclipse.jgit.revwalk.RevCommit;
27 | import org.eclipse.jgit.revwalk.RevWalk;
28 | import org.eclipse.jgit.revwalk.filter.RevFilter;
29 |
30 | /**
31 | * Filter that stops including commits after a certain number of commits are
32 | * considered. This class should be last in an {@link AndCommitFilter} if you
33 | * want to only limit matched commits and not just all visited commits.
34 | */
35 | public class CommitLimitFilter extends CommitFilter {
36 |
37 | private final long limit;
38 | private long count;
39 |
40 | /**
41 | * Create a limit filter
42 | *
43 | * @param limit
44 | */
45 | public CommitLimitFilter(final long limit) {
46 | this.limit = limit;
47 | }
48 |
49 | /**
50 | * Get configured limit
51 | *
52 | * @return limit
53 | */
54 | public long getLimit() {
55 | return limit;
56 | }
57 |
58 | @Override
59 | public boolean include(final RevWalk walker, final RevCommit commit)
60 | throws IOException {
61 | return include(count++ < limit);
62 | }
63 |
64 | @Override
65 | public CommitFilter reset() {
66 | count = 0L;
67 | return super.reset();
68 | }
69 |
70 | @Override
71 | public RevFilter clone() {
72 | return new CommitLimitFilter(limit);
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/CommitListFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.io.IOException;
25 | import java.util.ArrayList;
26 | import java.util.List;
27 |
28 | import org.eclipse.jgit.revwalk.RevCommit;
29 | import org.eclipse.jgit.revwalk.RevWalk;
30 | import org.eclipse.jgit.revwalk.filter.RevFilter;
31 |
32 | /**
33 | * Commit filter that adds each visited commit to a list that can be accessed.
34 | */
35 | public class CommitListFilter extends CommitFilter {
36 |
37 | private final List commits = new ArrayList();
38 |
39 | @Override
40 | public boolean include(final RevWalk walker, final RevCommit commit)
41 | throws IOException {
42 | commits.add(commit);
43 | return true;
44 | }
45 |
46 | /**
47 | * Get commits visited
48 | *
49 | * @return non-null but possibly empty list of commits
50 | */
51 | public List getCommits() {
52 | return commits;
53 | }
54 |
55 | @Override
56 | public CommitFilter reset() {
57 | commits.clear();
58 | return super.reset();
59 | }
60 |
61 | @Override
62 | public RevFilter clone() {
63 | return new CommitListFilter();
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/CommitMessageFindFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import org.eclipse.jgit.revwalk.RevCommit;
25 | import org.eclipse.jgit.revwalk.filter.RevFilter;
26 |
27 | /**
28 | * Base filter that includes commits where a pattern can be found in a commit's
29 | * full message.
30 | */
31 | public class CommitMessageFindFilter extends PatternFindCommitFilter {
32 |
33 | /**
34 | * Create a commit message pattern filter
35 | *
36 | * @param pattern
37 | */
38 | public CommitMessageFindFilter(final String pattern) {
39 | super(pattern);
40 | }
41 |
42 | /**
43 | * Create a commit message pattern filter
44 | *
45 | * @param pattern
46 | * @param flags
47 | */
48 | public CommitMessageFindFilter(final String pattern, final int flags) {
49 | super(pattern, flags);
50 | }
51 |
52 | @Override
53 | protected CharSequence getText(final RevCommit commit) {
54 | return commit.getFullMessage();
55 | }
56 |
57 | @Override
58 | public RevFilter clone() {
59 | return new CommitMessageFindFilter(pattern, flags);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/CommitterDateFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.util.Date;
25 |
26 | import org.eclipse.jgit.revwalk.RevCommit;
27 | import org.eclipse.jgit.revwalk.filter.RevFilter;
28 |
29 | /**
30 | * Filter that includes commits until a committed date is encountered that
31 | * occurred before the configured date.
32 | */
33 | public class CommitterDateFilter extends DateFilter {
34 |
35 | /**
36 | * Create a new committer date filter for the given date
37 | *
38 | * @param date
39 | */
40 | public CommitterDateFilter(final Date date) {
41 | super(date);
42 | }
43 |
44 | /**
45 | * Create a new committer date filter for the given time
46 | *
47 | * @param time
48 | */
49 | public CommitterDateFilter(final long time) {
50 | super(time);
51 | }
52 |
53 | @Override
54 | protected Date getDate(final RevCommit commit) {
55 | return getWhen(commit.getCommitterIdent());
56 | }
57 |
58 | @Override
59 | public RevFilter clone() {
60 | return new CommitterDateFilter(time);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/CommitterDiffFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.io.IOException;
25 |
26 | import org.eclipse.jgit.lib.PersonIdent;
27 | import org.eclipse.jgit.revwalk.RevCommit;
28 | import org.eclipse.jgit.revwalk.RevWalk;
29 | import org.eclipse.jgit.revwalk.filter.RevFilter;
30 | import org.gitective.core.Check;
31 |
32 | /**
33 | * Filter that includes commits where the committer name/e-mail address is
34 | * different than the author name/e-mail address.
35 | */
36 | public class CommitterDiffFilter extends CommitFilter {
37 |
38 | @Override
39 | public boolean include(final RevWalk walker, final RevCommit commit)
40 | throws IOException {
41 | final PersonIdent author = commit.getAuthorIdent();
42 | final PersonIdent committer = commit.getCommitterIdent();
43 | if (author != null && committer != null)
44 | return isSamePerson(author, committer) ? include(false) : true;
45 | if (author == null && committer == null)
46 | return include(false);
47 | return true;
48 | }
49 |
50 | /**
51 | * Are the two identities the same?
52 | *
53 | * @param author
54 | * @param committer
55 | * @return true is same, false otherwise
56 | */
57 | protected boolean isSamePerson(final PersonIdent author,
58 | final PersonIdent committer) {
59 | return Check.equals(author.getName(), committer.getName())
60 | && Check.equals(author.getEmailAddress(),
61 | committer.getEmailAddress());
62 | }
63 |
64 | @Override
65 | public RevFilter clone() {
66 | return new CommitterDiffFilter();
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/CommitterFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.io.IOException;
25 |
26 | import org.eclipse.jgit.lib.PersonIdent;
27 | import org.eclipse.jgit.revwalk.RevCommit;
28 | import org.eclipse.jgit.revwalk.RevWalk;
29 | import org.eclipse.jgit.revwalk.filter.RevFilter;
30 |
31 | /**
32 | * Person filter that includes commits where a {@link PersonIdent} matches the
33 | * name and e-mail address of the committer of a commit.
34 | */
35 | public class CommitterFilter extends PersonFilter {
36 |
37 | /**
38 | * Create a committer filter matching a {@link PersonIdent}
39 | *
40 | * @param person
41 | */
42 | public CommitterFilter(final PersonIdent person) {
43 | super(person);
44 | }
45 |
46 | /**
47 | * Create a committer filter matching a name and e-mail address
48 | *
49 | * @param name
50 | * @param email
51 | */
52 | public CommitterFilter(final String name, final String email) {
53 | super(name, email);
54 | }
55 |
56 | @Override
57 | public boolean include(final RevWalk walker, final RevCommit commit)
58 | throws IOException {
59 | return match(commit.getCommitterIdent()) ? true : include(false);
60 | }
61 |
62 | @Override
63 | public RevFilter clone() {
64 | return new CommitterFilter(name, email);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/CommitterSetFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import org.eclipse.jgit.lib.PersonIdent;
25 | import org.eclipse.jgit.revwalk.RevCommit;
26 | import org.eclipse.jgit.revwalk.filter.RevFilter;
27 |
28 | /**
29 | * Filter that collects committer {@link PersonIdent} objects for each commit
30 | * visited.
31 | */
32 | public class CommitterSetFilter extends PersonSetFilter {
33 |
34 | @Override
35 | protected PersonIdent getPerson(final RevCommit commit) {
36 | return commit.getCommitterIdent();
37 | }
38 |
39 | @Override
40 | public RevFilter clone() {
41 | return new CommitterSetFilter();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/DateFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.io.IOException;
25 | import java.util.Date;
26 |
27 | import org.eclipse.jgit.lib.PersonIdent;
28 | import org.eclipse.jgit.revwalk.RevCommit;
29 | import org.eclipse.jgit.revwalk.RevWalk;
30 | import org.gitective.core.Assert;
31 |
32 | /**
33 | * Commit filter that includes commits until one is encountered that returns a
34 | * date from {@link #getDate(RevCommit)} that has occurred before the configured
35 | * date.
36 | */
37 | public abstract class DateFilter extends CommitFilter {
38 |
39 | /**
40 | * Time
41 | */
42 | protected final long time;
43 |
44 | /**
45 | * Create a date filter for a given time
46 | *
47 | * @param time
48 | */
49 | public DateFilter(final long time) {
50 | this.time = time;
51 | }
52 |
53 | /**
54 | * Create a date filter for a given date
55 | *
56 | * @param date
57 | * must be non-null
58 | */
59 | public DateFilter(final Date date) {
60 | if (date == null)
61 | throw new IllegalArgumentException(Assert.formatNotNull("Date"));
62 |
63 | time = date.getTime();
64 | }
65 |
66 | @Override
67 | public boolean include(final RevWalk walker, final RevCommit commit)
68 | throws IOException {
69 | final Date date = getDate(commit);
70 | if (date == null)
71 | return include(false);
72 | if (date.getTime() < time)
73 | return include(false);
74 | return true;
75 | }
76 |
77 | /**
78 | * Get the date from a given {@link PersonIdent}
79 | *
80 | * @param person
81 | * @return date or null if given person is null
82 | */
83 | protected Date getWhen(final PersonIdent person) {
84 | return person != null ? person.getWhen() : null;
85 | }
86 |
87 | /**
88 | * Get a date from the commit to compare against
89 | *
90 | * @param commit
91 | * @return date
92 | */
93 | protected abstract Date getDate(RevCommit commit);
94 | }
95 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/DiffFileSizeFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.util.Collection;
25 |
26 | import org.eclipse.jgit.diff.DiffEntry;
27 | import org.eclipse.jgit.revwalk.RevCommit;
28 | import org.eclipse.jgit.revwalk.filter.RevFilter;
29 |
30 | /**
31 | * Filter for including commits that introduced a configurable number of file
32 | * differences per commit
33 | */
34 | public class DiffFileSizeFilter extends CommitDiffFilter {
35 |
36 | private final int total;
37 |
38 | /**
39 | * Create a filter that includes commits that introduced a minimum number of
40 | * file differences
41 | *
42 | * @param detectRenames
43 | * @param diffTotal
44 | */
45 | public DiffFileSizeFilter(final boolean detectRenames, final int diffTotal) {
46 | super(detectRenames);
47 | total = diffTotal;
48 | }
49 |
50 | /**
51 | * Create a filter that includes commits that introduced a minimum number of
52 | * file differences
53 | *
54 | * @param diffTotal
55 | */
56 | public DiffFileSizeFilter(final int diffTotal) {
57 | this(false, diffTotal);
58 | }
59 |
60 | /**
61 | * Get the configured difference total
62 | *
63 | * @return total
64 | */
65 | public int getTotal() {
66 | return total;
67 | }
68 |
69 | @Override
70 | public boolean include(final RevCommit commit,
71 | final Collection diffs) {
72 | if (diffs.size() < total)
73 | return false;
74 |
75 | int count = 0;
76 | for (DiffEntry diff : diffs)
77 | switch (diff.getChangeType()) {
78 | case ADD:
79 | case MODIFY:
80 | case DELETE:
81 | count++;
82 | if (count >= total)
83 | return true;
84 | }
85 | return false;
86 | }
87 |
88 | @Override
89 | public RevFilter clone() {
90 | return new DiffFileSizeFilter(detectRenames, total);
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/DiffLineCountFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import org.eclipse.jgit.diff.DiffEntry;
25 | import org.eclipse.jgit.diff.Edit;
26 | import org.eclipse.jgit.revwalk.RevCommit;
27 | import org.eclipse.jgit.revwalk.filter.RevFilter;
28 |
29 | /**
30 | * Filter that tracks the cumulative amount of lines added, edited, and deleted
31 | */
32 | public class DiffLineCountFilter extends CommitDiffEditFilter {
33 |
34 | private long added;
35 |
36 | private long edited;
37 |
38 | private long deleted;
39 |
40 | /**
41 | * Create diff line count filter
42 | */
43 | public DiffLineCountFilter() {
44 | super();
45 | }
46 |
47 | /**
48 | * Create diff line count filter
49 | *
50 | * @param detectRenames
51 | */
52 | public DiffLineCountFilter(final boolean detectRenames) {
53 | super(detectRenames);
54 | }
55 |
56 | /**
57 | * @return added
58 | */
59 | public long getAdded() {
60 | return added;
61 | }
62 |
63 | /**
64 | * @return edited
65 | */
66 | public long getEdited() {
67 | return edited;
68 | }
69 |
70 | /**
71 | * @return deleted
72 | */
73 | public long getDeleted() {
74 | return deleted;
75 | }
76 |
77 | /**
78 | * @return total
79 | */
80 | public long getTotal() {
81 | return added + edited + deleted;
82 | }
83 |
84 | protected boolean include(RevCommit commit, DiffEntry diff, Edit hunk) {
85 | switch (hunk.getType()) {
86 | case DELETE:
87 | deleted += hunk.getLengthA();
88 | break;
89 | case INSERT:
90 | added += hunk.getLengthB();
91 | break;
92 | case REPLACE:
93 | edited += hunk.getLengthB();
94 | break;
95 | }
96 | return true;
97 | }
98 |
99 | @Override
100 | public CommitFilter reset() {
101 | added = 0;
102 | edited = 0;
103 | deleted = 0;
104 | return super.reset();
105 | }
106 |
107 | @Override
108 | public RevFilter clone() {
109 | return new DiffLineCountFilter(detectRenames);
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/EmptyBlobAddFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import static org.eclipse.jgit.lib.Constants.EMPTY_BLOB_ID;
25 |
26 | import java.io.IOException;
27 | import java.util.Collection;
28 |
29 | import org.eclipse.jgit.diff.DiffEntry;
30 | import org.eclipse.jgit.lib.AbbreviatedObjectId;
31 | import org.eclipse.jgit.revwalk.RevCommit;
32 | import org.eclipse.jgit.revwalk.filter.RevFilter;
33 |
34 | /**
35 | * Filter that includes commits that add an empty blob.
36 | *
37 | * The commits included will either add a new file that is empty or edit an
38 | * existing file that was previously not empty but edited to be empty in the
39 | * given commit.
40 | */
41 | public class EmptyBlobAddFilter extends CommitDiffFilter {
42 |
43 | /**
44 | * Create empty blob add filter
45 | */
46 | public EmptyBlobAddFilter() {
47 | super();
48 | }
49 |
50 | /**
51 | * Create empty blob add filter
52 | *
53 | * @param detectRenames
54 | */
55 | public EmptyBlobAddFilter(final boolean detectRenames) {
56 | super(detectRenames);
57 | }
58 |
59 | @Override
60 | public boolean include(final RevCommit commit,
61 | final Collection diffs) throws IOException {
62 | for (DiffEntry diff : diffs) {
63 | final AbbreviatedObjectId oldId = diff.getOldId();
64 | if (oldId == null)
65 | continue;
66 | if (!EMPTY_BLOB_ID.equals(oldId.toObjectId())
67 | && EMPTY_BLOB_ID.equals(diff.getNewId().toObjectId()))
68 | return true;
69 | }
70 | return false;
71 | }
72 |
73 | @Override
74 | public RevFilter clone() {
75 | return new EmptyBlobAddFilter(detectRenames);
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/EmptyBlobRemoveFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import static org.eclipse.jgit.lib.Constants.EMPTY_BLOB_ID;
25 |
26 | import java.io.IOException;
27 | import java.util.Collection;
28 |
29 | import org.eclipse.jgit.diff.DiffEntry;
30 | import org.eclipse.jgit.lib.AbbreviatedObjectId;
31 | import org.eclipse.jgit.revwalk.RevCommit;
32 | import org.eclipse.jgit.revwalk.filter.RevFilter;
33 |
34 | /**
35 | * Filter that includes commits that remove an empty blob
36 | *
37 | * The commits included will either delete an existing empty file or edit an
38 | * existing file that was empty but edited to be no longer empty in the given
39 | * commit.
40 | */
41 | public class EmptyBlobRemoveFilter extends CommitDiffFilter {
42 |
43 | /**
44 | * Create empty blob add filter
45 | */
46 | public EmptyBlobRemoveFilter() {
47 | super();
48 | }
49 |
50 | /**
51 | * Create empty blob add filter
52 | *
53 | * @param detectRenames
54 | */
55 | public EmptyBlobRemoveFilter(final boolean detectRenames) {
56 | super(detectRenames);
57 | }
58 |
59 | @Override
60 | public boolean include(final RevCommit commit,
61 | final Collection diffs) throws IOException {
62 | for (DiffEntry diff : diffs) {
63 | final AbbreviatedObjectId oldId = diff.getOldId();
64 | if (oldId == null)
65 | continue;
66 | if (EMPTY_BLOB_ID.equals(oldId.toObjectId())
67 | && !EMPTY_BLOB_ID.equals(diff.getNewId().toObjectId()))
68 | return true;
69 | }
70 | return false;
71 | }
72 |
73 | @Override
74 | public RevFilter clone() {
75 | return new EmptyBlobRemoveFilter(detectRenames);
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/LastCommitFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.io.IOException;
25 |
26 | import org.eclipse.jgit.revwalk.RevCommit;
27 | import org.eclipse.jgit.revwalk.RevWalk;
28 | import org.eclipse.jgit.revwalk.filter.RevFilter;
29 |
30 | /**
31 | * Commit filter that retains the last commit seen via a call to
32 | * {@link #include(RevWalk, RevCommit)}. The last commit seen is available
33 | * through calling {@link #getLast()} and can be cleared through calling
34 | * {@link #reset()} on this filter.
35 | */
36 | public class LastCommitFilter extends CommitFilter {
37 |
38 | private RevCommit last;
39 |
40 | @Override
41 | public boolean include(final RevWalk walker, final RevCommit commit)
42 | throws IOException {
43 | last = commit;
44 | return true;
45 | }
46 |
47 | /**
48 | * Get last commit seen
49 | *
50 | * @return commit or null if none seen since creation or last reset
51 | */
52 | public RevCommit getLast() {
53 | return last;
54 | }
55 |
56 | @Override
57 | public CommitFilter reset() {
58 | last = null;
59 | return super.reset();
60 | }
61 |
62 | @Override
63 | public RevFilter clone() {
64 | return new LastCommitFilter();
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/LongestAuthorEmailFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.util.Set;
25 |
26 | import org.eclipse.jgit.lib.PersonIdent;
27 | import org.eclipse.jgit.revwalk.RevCommit;
28 | import org.eclipse.jgit.revwalk.RevWalk;
29 |
30 | /**
31 | * Filter to track the commit(s) with the longest author email address
32 | */
33 | public class LongestAuthorEmailFilter extends LongestPersonEmailFilter {
34 |
35 | @Override
36 | protected PersonIdent getPerson(RevWalk walker, RevCommit commit) {
37 | return commit.getAuthorIdent();
38 | }
39 |
40 | /**
41 | * Get the commits with the longest author email address length
42 | *
43 | * @return non-null but possibly empty set of commits
44 | */
45 | public Set getCommits() {
46 | return commits;
47 | }
48 |
49 | /**
50 | * Get the length of the longest commit author email address visited
51 | *
52 | * @return length or -1 if no commits visited
53 | */
54 | public int getLength() {
55 | return length;
56 | }
57 |
58 | @Override
59 | public LongestAuthorEmailFilter clone() {
60 | return new LongestAuthorEmailFilter();
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/LongestAuthorNameFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.util.Set;
25 |
26 | import org.eclipse.jgit.lib.PersonIdent;
27 | import org.eclipse.jgit.revwalk.RevCommit;
28 | import org.eclipse.jgit.revwalk.RevWalk;
29 |
30 | /**
31 | * Filter to track the commit(s) with the longest author name
32 | */
33 | public class LongestAuthorNameFilter extends LongestPersonNameFilter {
34 |
35 | @Override
36 | protected PersonIdent getPerson(RevWalk walker, RevCommit commit) {
37 | return commit.getAuthorIdent();
38 | }
39 |
40 | /**
41 | * Get the commits with the longest author name
42 | *
43 | * @return non-null but possibly empty set of commits
44 | */
45 | public Set getCommits() {
46 | return commits;
47 | }
48 |
49 | /**
50 | * Get the length of the longest commit author name
51 | *
52 | * @return length or -1 if no commits visited
53 | */
54 | public int getLength() {
55 | return length;
56 | }
57 |
58 | @Override
59 | public LongestAuthorNameFilter clone() {
60 | return new LongestAuthorNameFilter();
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/LongestCommitterEmailFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.util.Set;
25 |
26 | import org.eclipse.jgit.lib.PersonIdent;
27 | import org.eclipse.jgit.revwalk.RevCommit;
28 | import org.eclipse.jgit.revwalk.RevWalk;
29 |
30 | /**
31 | * Filter to track the commit(s) with the longest committer email address
32 | */
33 | public class LongestCommitterEmailFilter extends LongestPersonEmailFilter {
34 |
35 | @Override
36 | protected PersonIdent getPerson(RevWalk walker, RevCommit commit) {
37 | return commit.getCommitterIdent();
38 | }
39 |
40 | /**
41 | * Get the commits with the longest committer email address length
42 | *
43 | * @return non-null but possibly empty set of commits
44 | */
45 | public Set getCommits() {
46 | return commits;
47 | }
48 |
49 | /**
50 | * Get the length of the longest commit committer email address visited
51 | *
52 | * @return length or -1 if no commits visited
53 | */
54 | public int getLength() {
55 | return length;
56 | }
57 |
58 | @Override
59 | public LongestCommitterEmailFilter clone() {
60 | return new LongestCommitterEmailFilter();
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/LongestCommitterNameFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.util.Set;
25 |
26 | import org.eclipse.jgit.lib.PersonIdent;
27 | import org.eclipse.jgit.revwalk.RevCommit;
28 | import org.eclipse.jgit.revwalk.RevWalk;
29 |
30 | /**
31 | * Filter to track the commit(s) with the longest committer name
32 | */
33 | public class LongestCommitterNameFilter extends LongestPersonNameFilter {
34 |
35 | @Override
36 | protected PersonIdent getPerson(RevWalk walker, RevCommit commit) {
37 | return commit.getCommitterIdent();
38 | }
39 |
40 | /**
41 | * Get the commits with the longest committer name
42 | *
43 | * @return non-null but possibly empty set of commits
44 | */
45 | public Set getCommits() {
46 | return commits;
47 | }
48 |
49 | /**
50 | * Get the length of the longest commit committer name
51 | *
52 | * @return length or -1 if no commits visited
53 | */
54 | public int getLength() {
55 | return length;
56 | }
57 |
58 | @Override
59 | public LongestCommitterNameFilter clone() {
60 | return new LongestCommitterNameFilter();
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/LongestMessageFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.io.IOException;
25 | import java.util.Set;
26 |
27 | import org.eclipse.jgit.revwalk.RevCommit;
28 | import org.eclipse.jgit.revwalk.RevWalk;
29 |
30 | /**
31 | * Filter to track the commit(s) with the longest message
32 | */
33 | public class LongestMessageFilter extends CommitFieldLengthFilter {
34 |
35 | @Override
36 | public boolean include(final RevWalk walker, final RevCommit commit)
37 | throws IOException {
38 | final int messageLength = commit.getFullMessage().length();
39 | if (messageLength >= length)
40 | include(messageLength, commit);
41 | return true;
42 | }
43 |
44 | /**
45 | * Get the commits with the longest message length
46 | *
47 | * @return non-null but possibly empty set of commits
48 | */
49 | public Set getCommits() {
50 | return commits;
51 | }
52 |
53 | /**
54 | * Get the length of the longest commit message visited
55 | *
56 | * @return length or -1 if no commits visited
57 | */
58 | public int getLength() {
59 | return length;
60 | }
61 |
62 | @Override
63 | public LongestMessageFilter clone() {
64 | return new LongestMessageFilter();
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/LongestPersonEmailFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.io.IOException;
25 |
26 | import org.eclipse.jgit.lib.PersonIdent;
27 | import org.eclipse.jgit.revwalk.RevCommit;
28 | import org.eclipse.jgit.revwalk.RevWalk;
29 |
30 | /**
31 | * Base filter to track the commit(s) with the longest email address for a
32 | * {@link PersonIdent} associated with each commit
33 | */
34 | public abstract class LongestPersonEmailFilter extends CommitFieldLengthFilter {
35 |
36 | @Override
37 | public boolean include(final RevWalk walker, final RevCommit commit)
38 | throws IOException {
39 | final PersonIdent person = getPerson(walker, commit);
40 | if (person == null)
41 | return true;
42 | final String email = person.getEmailAddress();
43 | final int emailLength = email != null ? email.length() : 0;
44 | if (emailLength >= length)
45 | include(emailLength, commit);
46 | return true;
47 | }
48 |
49 | /**
50 | * Get person from commit
51 | *
52 | * @param walker
53 | * @param commit
54 | * @return person
55 | */
56 | protected abstract PersonIdent getPerson(final RevWalk walker,
57 | final RevCommit commit);
58 | }
59 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/LongestPersonNameFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.io.IOException;
25 |
26 | import org.eclipse.jgit.lib.PersonIdent;
27 | import org.eclipse.jgit.revwalk.RevCommit;
28 | import org.eclipse.jgit.revwalk.RevWalk;
29 |
30 | /**
31 | * Base filter to track the commit(s) with the longest name for a
32 | * {@link PersonIdent} associated with each commit
33 | */
34 | public abstract class LongestPersonNameFilter extends CommitFieldLengthFilter {
35 |
36 | @Override
37 | public boolean include(final RevWalk walker, final RevCommit commit)
38 | throws IOException {
39 | final PersonIdent person = getPerson(walker, commit);
40 | if (person == null)
41 | return true;
42 | final String name = person.getName();
43 | final int nameLength = name != null ? name.length() : 0;
44 | if (nameLength >= length)
45 | include(nameLength, commit);
46 | return true;
47 | }
48 |
49 | /**
50 | * Get person from commit
51 | *
52 | * @param walker
53 | * @param commit
54 | * @return person
55 | */
56 | protected abstract PersonIdent getPerson(final RevWalk walker,
57 | final RevCommit commit);
58 | }
59 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/NoteFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.io.IOException;
25 | import java.util.Collection;
26 |
27 | import org.eclipse.jgit.api.Git;
28 | import org.eclipse.jgit.api.ShowNoteCommand;
29 | import org.eclipse.jgit.api.errors.GitAPIException;
30 | import org.eclipse.jgit.lib.Repository;
31 | import org.eclipse.jgit.revwalk.RevCommit;
32 | import org.eclipse.jgit.revwalk.RevWalk;
33 | import org.eclipse.jgit.revwalk.filter.RevFilter;
34 | import org.gitective.core.RepositoryUtils;
35 |
36 | /**
37 | * Filter that only includes commits that have at least one note attached
38 | */
39 | public class NoteFilter extends CommitFilter {
40 |
41 | private ShowNoteCommand show;
42 |
43 | private String[] noteRefs;
44 |
45 | @Override
46 | public CommitFilter setRepository(final Repository repository) {
47 | super.setRepository(repository);
48 | if (repository != null) {
49 | show = Git.wrap(repository).notesShow();
50 | noteRefs = getNoteRefs(repository);
51 | } else {
52 | show = null;
53 | noteRefs = null;
54 | }
55 | return this;
56 | }
57 |
58 | /**
59 | * Get note refs from repository to use during commit walks.
60 | *
61 | * @param repository
62 | * non-null
63 | * @return non-null array of ref names
64 | */
65 | protected String[] getNoteRefs(final Repository repository) {
66 | Collection refs = RepositoryUtils.getNoteRefs(repository);
67 | return refs.toArray(new String[refs.size()]);
68 | }
69 |
70 | @Override
71 | public boolean include(final RevWalk walker, final RevCommit commit)
72 | throws IOException {
73 | show.setObjectId(commit);
74 | final int refLength = noteRefs.length;
75 | for (int i = 0; i < refLength; i++)
76 | try {
77 | if (show.setNotesRef(noteRefs[i]).call() != null)
78 | return true;
79 | } catch (GitAPIException e) {
80 | throwIOException(e, "Exception showing notes");
81 | }
82 | return include(false);
83 | }
84 |
85 | @Override
86 | public RevFilter clone() {
87 | return new NoteFilter();
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/OrCommitFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.io.IOException;
25 |
26 | import org.eclipse.jgit.revwalk.RevCommit;
27 | import org.eclipse.jgit.revwalk.RevWalk;
28 | import org.eclipse.jgit.revwalk.filter.RevFilter;
29 |
30 | /**
31 | * Composite filter that only includes commits that are included by at least one
32 | * child filter that has been added to this filter.
33 | *
34 | * This filter stops matching against child filters when the first child filter
35 | * matches the current commit.
36 | */
37 | public class OrCommitFilter extends CompositeCommitFilter {
38 |
39 | /**
40 | * Create an empty or commit filter
41 | */
42 | public OrCommitFilter() {
43 | super();
44 | }
45 |
46 | /**
47 | * Create an or commit filter with given child filters
48 | *
49 | * @param filters
50 | */
51 | public OrCommitFilter(final RevFilter... filters) {
52 | super(filters);
53 | }
54 |
55 | @Override
56 | public boolean include(final RevWalk walker, final RevCommit commit)
57 | throws IOException {
58 | final int length = filters.length;
59 | for (int i = 0; i < length; i++)
60 | if (filters[i].include(walker, commit))
61 | return true;
62 | return include(false);
63 | }
64 |
65 | @Override
66 | public RevFilter clone() {
67 | return new OrCommitFilter(cloneFilters());
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/ParentCountFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import static java.lang.Integer.MAX_VALUE;
25 |
26 | import java.io.IOException;
27 |
28 | import org.eclipse.jgit.revwalk.RevCommit;
29 | import org.eclipse.jgit.revwalk.RevWalk;
30 | import org.eclipse.jgit.revwalk.filter.RevFilter;
31 |
32 | /**
33 | * Commit filter that includes commits that match the range of number of
34 | * parents.
35 | */
36 | public class ParentCountFilter extends CommitFilter {
37 |
38 | private final int min;
39 |
40 | private final int max;
41 |
42 | /**
43 | * Create a parent count filter that includes commits that have at least 2
44 | * parents.
45 | */
46 | public ParentCountFilter() {
47 | this(2);
48 | }
49 |
50 | /**
51 | * Create a filter that includes commits that have a parent commit count of
52 | * at least the number specified.
53 | *
54 | * @param min
55 | * minimum number of parent commits (inclusive)
56 | */
57 | public ParentCountFilter(final int min) {
58 | this(min, MAX_VALUE);
59 | }
60 |
61 | /**
62 | * Create a filter that includes commits that have a parent commit count
63 | * that falls inclusively in the specified range.
64 | *
65 | * @param min
66 | * minimum number of parent commits (inclusive)
67 | * @param max
68 | * maximum number of parent commits (inclusive)
69 | */
70 | public ParentCountFilter(final int min, final int max) {
71 | this.min = min;
72 | this.max = max;
73 | }
74 |
75 | @Override
76 | public boolean include(final RevWalk walker, final RevCommit commit)
77 | throws IOException {
78 | final int parents = commit.getParentCount();
79 | if (parents < min || parents > max)
80 | return include(false);
81 | return true;
82 | }
83 |
84 | @Override
85 | public RevFilter clone() {
86 | return new ParentCountFilter(min, max);
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/PatternFindCommitFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.io.IOException;
25 | import java.util.regex.Matcher;
26 | import java.util.regex.Pattern;
27 |
28 | import org.eclipse.jgit.revwalk.RevCommit;
29 | import org.eclipse.jgit.revwalk.RevWalk;
30 | import org.gitective.core.Assert;
31 |
32 | /**
33 | * Base commit filter class that includes commits where a configured pattern can
34 | * be found.
35 | */
36 | public abstract class PatternFindCommitFilter extends CommitFilter {
37 |
38 | /**
39 | * Pattern
40 | */
41 | protected final String pattern;
42 |
43 | /**
44 | * Flags
45 | */
46 | protected final int flags;
47 |
48 | /**
49 | * Pattern matcher
50 | */
51 | protected final Matcher matcher;
52 |
53 | /**
54 | * Create a pattern find commit filter
55 | *
56 | * @param pattern
57 | */
58 | public PatternFindCommitFilter(final String pattern) {
59 | this(pattern, 0);
60 | }
61 |
62 | /**
63 | * Create a pattern find commit filter
64 | *
65 | * @param pattern
66 | * @param flags
67 | */
68 | public PatternFindCommitFilter(final String pattern, final int flags) {
69 | if (pattern == null)
70 | throw new IllegalArgumentException(Assert.formatNotNull("Pattern"));
71 | if (pattern.length() == 0)
72 | throw new IllegalArgumentException(Assert.formatNotEmpty("Pattern"));
73 |
74 | this.pattern = pattern;
75 | this.flags = flags;
76 | matcher = Pattern.compile(pattern, flags).matcher("");
77 | }
78 |
79 | @Override
80 | public boolean include(final RevWalk walker, final RevCommit commit)
81 | throws IOException {
82 | return matcher.reset(getText(commit)).find() ? true : include(false);
83 | }
84 |
85 | /**
86 | * Get the text from the commit to find the pattern in
87 | *
88 | * @param commit
89 | * @return text
90 | */
91 | protected abstract CharSequence getText(RevCommit commit);
92 | }
93 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/PersonFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import org.eclipse.jgit.lib.PersonIdent;
25 |
26 | /**
27 | * Base commit filter that contains utility methods for matching the configured
28 | * {@link PersonIdent}.
29 | */
30 | public abstract class PersonFilter extends CommitFilter {
31 |
32 | /**
33 | * Name matching against
34 | */
35 | protected final String name;
36 |
37 | /**
38 | * E-mail matching against
39 | */
40 | protected final String email;
41 |
42 | /**
43 | * Create a person filter
44 | *
45 | * @param name
46 | * @param email
47 | */
48 | public PersonFilter(final String name, final String email) {
49 | this.name = name;
50 | this.email = email;
51 | }
52 |
53 | /**
54 | * Create a person filter
55 | *
56 | * @param person
57 | */
58 | public PersonFilter(final PersonIdent person) {
59 | if (person != null) {
60 | name = person.getName();
61 | email = person.getEmailAddress();
62 | } else {
63 | name = null;
64 | email = null;
65 | }
66 | }
67 |
68 | /**
69 | * Match the specified {@link PersonIdent} against the name and e-mail
70 | * address of the configured {@link PersonIdent}.
71 | *
72 | * @param ident
73 | * @return true on matches, false otherwise
74 | */
75 | protected boolean match(final PersonIdent ident) {
76 | if (ident == null)
77 | return name == null && email == null;
78 |
79 | if (name != null && !name.equals(ident.getName()))
80 | return false;
81 |
82 | if (email != null && !email.equals(ident.getEmailAddress()))
83 | return false;
84 |
85 | return true;
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/PersonSetFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.io.IOException;
25 | import java.util.Comparator;
26 | import java.util.Set;
27 | import java.util.TreeSet;
28 |
29 | import org.eclipse.jgit.lib.PersonIdent;
30 | import org.eclipse.jgit.revwalk.RevCommit;
31 | import org.eclipse.jgit.revwalk.RevWalk;
32 | import org.gitective.core.PersonComparator;
33 |
34 | /**
35 | * Commit filter that stores a set of persons encountered while visiting
36 | * commits.
37 | */
38 | public abstract class PersonSetFilter extends CommitFilter {
39 |
40 | /**
41 | * Persons
42 | */
43 | protected final Set persons;
44 |
45 | /**
46 | * Create a person set filter using a {@link PersonComparator}
47 | */
48 | public PersonSetFilter() {
49 | this(new PersonComparator());
50 | }
51 |
52 | /**
53 | * Create a person set filter using the given comparator
54 | *
55 | * @param comparator
56 | */
57 | public PersonSetFilter(final Comparator comparator) {
58 | persons = new TreeSet(comparator);
59 | }
60 |
61 | @Override
62 | public boolean include(final RevWalk walker, final RevCommit commit)
63 | throws IOException {
64 | final PersonIdent person = getPerson(commit);
65 | if (person != null)
66 | persons.add(person);
67 | return true;
68 | }
69 |
70 | @Override
71 | public CommitFilter reset() {
72 | persons.clear();
73 | return super.reset();
74 | }
75 |
76 | /**
77 | * Get persons encountered during commit visiting
78 | *
79 | * @return non-null but possibly empty set of persons
80 | */
81 | public Set getPersons() {
82 | return persons;
83 | }
84 |
85 | /**
86 | * Get the person from the commit to include in set
87 | *
88 | * @param commit
89 | * @return person
90 | */
91 | protected abstract PersonIdent getPerson(RevCommit commit);
92 | }
93 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/ShortestAuthorEmailFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import static java.lang.Integer.MAX_VALUE;
25 |
26 | import java.util.Set;
27 |
28 | import org.eclipse.jgit.lib.PersonIdent;
29 | import org.eclipse.jgit.revwalk.RevCommit;
30 | import org.eclipse.jgit.revwalk.RevWalk;
31 |
32 | /**
33 | * Filter to track the commit(s) with the shortest author email address
34 | */
35 | public class ShortestAuthorEmailFilter extends ShortestPersonEmailFilter {
36 |
37 | /**
38 | * Create shortest author email filter
39 | */
40 | public ShortestAuthorEmailFilter() {
41 | length = MAX_VALUE;
42 | }
43 |
44 | @Override
45 | protected PersonIdent getPerson(RevWalk walker, RevCommit commit) {
46 | return commit.getAuthorIdent();
47 | }
48 |
49 | /**
50 | * Get the commits with the shortest author email address length
51 | *
52 | * @return non-null but possibly empty set of commits
53 | */
54 | public Set getCommits() {
55 | return commits;
56 | }
57 |
58 | /**
59 | * Get the length of the shortest commit author email address visited
60 | *
61 | * @return length or -1 if no commits visited
62 | */
63 | public int getLength() {
64 | return commits.isEmpty() ? -1 : length;
65 | }
66 |
67 | @Override
68 | public ShortestAuthorEmailFilter clone() {
69 | return new ShortestAuthorEmailFilter();
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/ShortestAuthorNameFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import static java.lang.Integer.MAX_VALUE;
25 |
26 | import java.util.Set;
27 |
28 | import org.eclipse.jgit.lib.PersonIdent;
29 | import org.eclipse.jgit.revwalk.RevCommit;
30 | import org.eclipse.jgit.revwalk.RevWalk;
31 |
32 | /**
33 | * Filter to track the commit(s) with the shortest author name
34 | */
35 | public class ShortestAuthorNameFilter extends ShortestPersonNameFilter {
36 |
37 | /**
38 | * Create shortest author name filter
39 | */
40 | public ShortestAuthorNameFilter() {
41 | length = MAX_VALUE;
42 | }
43 |
44 | @Override
45 | protected PersonIdent getPerson(RevWalk walker, RevCommit commit) {
46 | return commit.getAuthorIdent();
47 | }
48 |
49 | /**
50 | * Get the commits with the shortest author name
51 | *
52 | * @return non-null but possibly empty set of commits
53 | */
54 | public Set getCommits() {
55 | return commits;
56 | }
57 |
58 | /**
59 | * Get the length of the shortest commit author name
60 | *
61 | * @return length or -1 if no commits visited
62 | */
63 | public int getLength() {
64 | return commits.isEmpty() ? -1 : length;
65 | }
66 |
67 | @Override
68 | public ShortestAuthorNameFilter clone() {
69 | return new ShortestAuthorNameFilter();
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/ShortestCommitterEmailFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import static java.lang.Integer.MAX_VALUE;
25 |
26 | import java.util.Set;
27 |
28 | import org.eclipse.jgit.lib.PersonIdent;
29 | import org.eclipse.jgit.revwalk.RevCommit;
30 | import org.eclipse.jgit.revwalk.RevWalk;
31 |
32 | /**
33 | * Filter to track the commit(s) with the shortest author email address
34 | */
35 | public class ShortestCommitterEmailFilter extends ShortestPersonEmailFilter {
36 |
37 | /**
38 | * Create shortest committer email filter
39 | */
40 | public ShortestCommitterEmailFilter() {
41 | length = MAX_VALUE;
42 | }
43 |
44 | @Override
45 | protected PersonIdent getPerson(RevWalk walker, RevCommit commit) {
46 | return commit.getCommitterIdent();
47 | }
48 |
49 | /**
50 | * Get the commits with the shortest committer email address length
51 | *
52 | * @return non-null but possibly empty set of commits
53 | */
54 | public Set getCommits() {
55 | return commits;
56 | }
57 |
58 | /**
59 | * Get the length of the shortest commit committer email address visited
60 | *
61 | * @return length or -1 if no commits visited
62 | */
63 | public int getLength() {
64 | return commits.isEmpty() ? -1 : length;
65 | }
66 |
67 | @Override
68 | public ShortestCommitterEmailFilter clone() {
69 | return new ShortestCommitterEmailFilter();
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/ShortestCommitterNameFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import static java.lang.Integer.MAX_VALUE;
25 |
26 | import java.util.Set;
27 |
28 | import org.eclipse.jgit.lib.PersonIdent;
29 | import org.eclipse.jgit.revwalk.RevCommit;
30 | import org.eclipse.jgit.revwalk.RevWalk;
31 |
32 | /**
33 | * Filter to track the commit(s) with the shortest committer name
34 | */
35 | public class ShortestCommitterNameFilter extends ShortestPersonNameFilter {
36 |
37 | /**
38 | * Create shortest committer name filter
39 | */
40 | public ShortestCommitterNameFilter() {
41 | length = MAX_VALUE;
42 | }
43 |
44 | @Override
45 | protected PersonIdent getPerson(RevWalk walker, RevCommit commit) {
46 | return commit.getCommitterIdent();
47 | }
48 |
49 | /**
50 | * Get the commits with the shortest committer name
51 | *
52 | * @return non-null but possibly empty set of commits
53 | */
54 | public Set getCommits() {
55 | return commits;
56 | }
57 |
58 | /**
59 | * Get the length of the shortest commit committer name
60 | *
61 | * @return length or -1 if no commits visited
62 | */
63 | public int getLength() {
64 | return commits.isEmpty() ? -1 : length;
65 | }
66 |
67 | @Override
68 | public ShortestCommitterNameFilter clone() {
69 | return new ShortestCommitterNameFilter();
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/ShortestMessageFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import static java.lang.Integer.MAX_VALUE;
25 |
26 | import java.io.IOException;
27 | import java.util.Set;
28 |
29 | import org.eclipse.jgit.revwalk.RevCommit;
30 | import org.eclipse.jgit.revwalk.RevWalk;
31 |
32 | /**
33 | * Filter to track the commit(s) with the shortest message
34 | */
35 | public class ShortestMessageFilter extends CommitFieldLengthFilter {
36 |
37 | /**
38 | * Create shortest message filter
39 | */
40 | public ShortestMessageFilter() {
41 | length = MAX_VALUE;
42 | }
43 |
44 | @Override
45 | public boolean include(final RevWalk walker, final RevCommit commit)
46 | throws IOException {
47 | final int messageLength = commit.getFullMessage().length();
48 | if (messageLength <= length)
49 | include(messageLength, commit);
50 | return true;
51 | }
52 |
53 | /**
54 | * Get the commits with the shortest message length
55 | *
56 | * @return non-null but possibly empty set of commits
57 | */
58 | public Set getCommits() {
59 | return commits;
60 | }
61 |
62 | /**
63 | * Get the length of the shortest commit message visited
64 | *
65 | * @return length or -1 if no commits visited
66 | */
67 | public int getLength() {
68 | return commits.isEmpty() ? -1 : length;
69 | }
70 |
71 | @Override
72 | public ShortestMessageFilter clone() {
73 | return new ShortestMessageFilter();
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/ShortestPersonEmailFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.io.IOException;
25 |
26 | import org.eclipse.jgit.lib.PersonIdent;
27 | import org.eclipse.jgit.revwalk.RevCommit;
28 | import org.eclipse.jgit.revwalk.RevWalk;
29 |
30 | /**
31 | * Base filter to track the commit(s) with the shortest email address for a
32 | * {@link PersonIdent} associated with each commit
33 | */
34 | public abstract class ShortestPersonEmailFilter extends CommitFieldLengthFilter {
35 |
36 | @Override
37 | public boolean include(final RevWalk walker, final RevCommit commit)
38 | throws IOException {
39 | final PersonIdent person = getPerson(walker, commit);
40 | if (person == null)
41 | return true;
42 | final String email = person.getEmailAddress();
43 | final int emailLength = email != null ? email.length() : 0;
44 | if (emailLength <= length)
45 | include(emailLength, commit);
46 | return true;
47 | }
48 |
49 | /**
50 | * Get person from commit
51 | *
52 | * @param walker
53 | * @param commit
54 | * @return person
55 | */
56 | protected abstract PersonIdent getPerson(final RevWalk walker,
57 | final RevCommit commit);
58 | }
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/ShortestPersonNameFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import java.io.IOException;
25 |
26 | import org.eclipse.jgit.lib.PersonIdent;
27 | import org.eclipse.jgit.revwalk.RevCommit;
28 | import org.eclipse.jgit.revwalk.RevWalk;
29 |
30 | /**
31 | * Base filter to track the commit(s) with the shortest name for a
32 | * {@link PersonIdent} associated with each commit
33 | */
34 | public abstract class ShortestPersonNameFilter extends CommitFieldLengthFilter {
35 |
36 | @Override
37 | public boolean include(final RevWalk walker, final RevCommit commit)
38 | throws IOException {
39 | final PersonIdent person = getPerson(walker, commit);
40 | if (person == null)
41 | return true;
42 | final String name = person.getName();
43 | final int nameLength = name != null ? name.length() : 0;
44 | if (nameLength <= length)
45 | include(nameLength, commit);
46 | return true;
47 | }
48 |
49 | /**
50 | * Get person from commit
51 | *
52 | * @param walker
53 | * @param commit
54 | * @return person
55 | */
56 | protected abstract PersonIdent getPerson(final RevWalk walker,
57 | final RevCommit commit);
58 | }
59 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/commit/SignedOffByFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.commit;
23 |
24 | import static java.util.regex.Pattern.MULTILINE;
25 | import static org.eclipse.jgit.lib.Constants.SIGNED_OFF_BY_TAG;
26 |
27 | import java.text.MessageFormat;
28 | import java.util.regex.Pattern;
29 |
30 | import org.eclipse.jgit.lib.PersonIdent;
31 | import org.eclipse.jgit.revwalk.filter.RevFilter;
32 |
33 | /**
34 | * Commit message pattern filter that includes commit that have a Signed-off-by
35 | * line for a person.
36 | */
37 | public class SignedOffByFilter extends CommitMessageFindFilter {
38 |
39 | /**
40 | * Signed off by format
41 | */
42 | public static final String SIGNED_OFF_BY = SIGNED_OFF_BY_TAG + "{0} <{1}>";
43 |
44 | private final PersonIdent person;
45 |
46 | /**
47 | * Create a signed off by filter matching the person
48 | *
49 | * @param person
50 | * must be non-null
51 | */
52 | public SignedOffByFilter(final PersonIdent person) {
53 | super(Pattern.quote(MessageFormat.format(SIGNED_OFF_BY,
54 | person.getName(), person.getEmailAddress())), MULTILINE);
55 | this.person = person;
56 | }
57 |
58 | @Override
59 | public RevFilter clone() {
60 | return new SignedOffByFilter(person);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/tree/CommitTreeFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.tree;
23 |
24 | import java.io.IOException;
25 |
26 | import org.eclipse.jgit.lib.Repository;
27 | import org.eclipse.jgit.revwalk.RevCommit;
28 | import org.eclipse.jgit.revwalk.RevWalk;
29 | import org.eclipse.jgit.treewalk.TreeWalk;
30 | import org.eclipse.jgit.treewalk.filter.TreeFilter;
31 | import org.gitective.core.filter.commit.CommitFilter;
32 |
33 | /**
34 | * Filter that wraps a {@link TreeFilter} and includes commits included by the
35 | * tree filter for all paths in the tree for the current commit visited
36 | */
37 | public class CommitTreeFilter extends CommitFilter {
38 |
39 | private final BaseTreeFilter filter;
40 |
41 | /**
42 | * Create commit filter for given tree filter
43 | *
44 | * @param filter
45 | */
46 | public CommitTreeFilter(final TreeFilter filter) {
47 | this.filter = BaseTreeFilter.wrap(filter);
48 | }
49 |
50 | @Override
51 | public CommitFilter setRepository(final Repository repository) {
52 | filter.setRepository(repository);
53 | return super.setRepository(repository);
54 | }
55 |
56 | @Override
57 | public CommitFilter reset() {
58 | filter.reset();
59 | return super.reset();
60 | }
61 |
62 | @Override
63 | public boolean include(final RevWalk walker, final RevCommit commit)
64 | throws IOException {
65 | final TreeWalk walk = new TreeWalk(walker.getObjectReader());
66 | walk.addTree(commit.getTree());
67 | while (walk.next()) {
68 | if (!filter.include(walker, commit, walk))
69 | return include(false);
70 | if (walk.isSubtree())
71 | walk.enterSubtree();
72 | }
73 | return true;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/filter/tree/ExtensionOccurrence.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.filter.tree;
23 |
24 | /**
25 | * Class representing the occurrences of a file extension
26 | */
27 | public class ExtensionOccurrence {
28 |
29 | /**
30 | * Number of occurrences
31 | */
32 | protected int count;
33 |
34 | private final String extension;
35 |
36 | /**
37 | * Create occurrence for given extension
38 | *
39 | * @param extension
40 | * must be non-null
41 | */
42 | protected ExtensionOccurrence(final String extension) {
43 | this.extension = extension;
44 | count = 1;
45 | }
46 |
47 | /**
48 | * Get number of occurrences
49 | *
50 | * @return count
51 | */
52 | public int getCount() {
53 | return count;
54 | }
55 |
56 | /**
57 | * Get extension
58 | *
59 | * @return extension
60 | */
61 | public String getExtension() {
62 | return extension;
63 | }
64 |
65 | public int hashCode() {
66 | return toString().hashCode();
67 | }
68 |
69 | public boolean equals(final Object obj) {
70 | if (obj == this)
71 | return true;
72 | if (!(obj instanceof ExtensionOccurrence))
73 | return false;
74 | final ExtensionOccurrence other = (ExtensionOccurrence) obj;
75 | return count == other.count && extension.equals(other.extension);
76 | }
77 |
78 | public String toString() {
79 | return extension + "=" + count;
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/stat/AuthorHistogramFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.stat;
23 |
24 | import java.io.IOException;
25 |
26 | import org.eclipse.jgit.lib.PersonIdent;
27 | import org.eclipse.jgit.revwalk.RevCommit;
28 | import org.eclipse.jgit.revwalk.RevWalk;
29 | import org.eclipse.jgit.revwalk.filter.RevFilter;
30 |
31 | /**
32 | * Filter that generates a commit histogram based on the author date of each
33 | * commit visited.
34 | */
35 | public class AuthorHistogramFilter extends CommitHistogramFilter {
36 |
37 | @Override
38 | public boolean include(final RevWalk walker, final RevCommit commit)
39 | throws IOException {
40 | final PersonIdent author = commit.getAuthorIdent();
41 | if (author != null)
42 | histogram.include(commit, author);
43 | return true;
44 | }
45 |
46 | @Override
47 | public RevFilter clone() {
48 | return new AuthorHistogramFilter();
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/stat/CommitCountComparator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.stat;
23 |
24 | import java.io.Serializable;
25 | import java.util.Comparator;
26 |
27 | /**
28 | * Comparator that sorts by most user activity first
29 | */
30 | public class CommitCountComparator implements Comparator,
31 | Serializable {
32 |
33 | /** serialVersionUID */
34 | private static final long serialVersionUID = -4952333917951609993L;
35 |
36 | public int compare(final UserCommitActivity u1, final UserCommitActivity u2) {
37 | final int c1 = u1.getCount();
38 | final int c2 = u2.getCount();
39 | if (c1 > c2)
40 | return -1;
41 | if (c1 < c2)
42 | return 1;
43 | return 0;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/stat/CommitHistogramFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.stat;
23 |
24 | import org.gitective.core.filter.commit.CommitFilter;
25 |
26 | /**
27 | * Base filter that generates a histogram of commits. The current histogram is
28 | * can be accessed through the {@link #getHistogram()} and can be reset through
29 | * invoking {@link #reset()} on this filter.
30 | */
31 | public abstract class CommitHistogramFilter extends CommitFilter {
32 |
33 | /**
34 | * Histogram
35 | */
36 | protected CommitHistogram histogram = new CommitHistogram();
37 |
38 | /**
39 | * Get generated histogram
40 | *
41 | * @return histogram
42 | */
43 | public CommitHistogram getHistogram() {
44 | return histogram;
45 | }
46 |
47 | @Override
48 | public CommitFilter reset() {
49 | histogram.clear();
50 | return super.reset();
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/stat/CommitterHistogramFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.stat;
23 |
24 | import java.io.IOException;
25 |
26 | import org.eclipse.jgit.lib.PersonIdent;
27 | import org.eclipse.jgit.revwalk.RevCommit;
28 | import org.eclipse.jgit.revwalk.RevWalk;
29 | import org.eclipse.jgit.revwalk.filter.RevFilter;
30 |
31 | /**
32 | * Filter that generates a commit histogram based on the committer date of each
33 | * commit visited.
34 | */
35 | public class CommitterHistogramFilter extends CommitHistogramFilter {
36 |
37 | @Override
38 | public boolean include(final RevWalk walker, final RevCommit commit)
39 | throws IOException {
40 | final PersonIdent committer = commit.getCommitterIdent();
41 | if (committer != null)
42 | histogram.include(commit, committer);
43 | return true;
44 | }
45 |
46 | @Override
47 | public RevFilter clone() {
48 | return new CommitterHistogramFilter();
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/stat/EarliestComparator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.stat;
23 |
24 | import java.io.Serializable;
25 | import java.util.Comparator;
26 |
27 | /**
28 | * Comparator that sorts by earliest user activity first
29 | */
30 | public class EarliestComparator implements Comparator,
31 | Serializable {
32 |
33 | /** serialVersionUID */
34 | private static final long serialVersionUID = 6380867895281659637L;
35 |
36 | public int compare(final UserCommitActivity u1, final UserCommitActivity u2) {
37 | final long e1 = u1.getEarliest();
38 | final long e2 = u2.getEarliest();
39 | if (e1 > e2)
40 | return 1;
41 | if (e1 < e2)
42 | return -1;
43 | return 0;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/stat/FileHistogramFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.stat;
23 |
24 | import java.util.Collection;
25 |
26 | import org.eclipse.jgit.diff.DiffEntry;
27 | import org.eclipse.jgit.revwalk.RevCommit;
28 | import org.eclipse.jgit.revwalk.filter.RevFilter;
29 | import org.gitective.core.filter.commit.CommitDiffFilter;
30 | import org.gitective.core.filter.commit.CommitFilter;
31 |
32 | /**
33 | * Filter that generates a histogram of the modified files introduced by each
34 | * commit visited.
35 | */
36 | public class FileHistogramFilter extends CommitDiffFilter {
37 |
38 | private FileHistogram histogram = new FileHistogram();
39 |
40 | /**
41 | * Create file histogram filter
42 | */
43 | public FileHistogramFilter() {
44 | super();
45 | }
46 |
47 | /**
48 | * Create file histogram filter
49 | *
50 | * @param detectRenames
51 | */
52 | public FileHistogramFilter(final boolean detectRenames) {
53 | super(detectRenames);
54 | }
55 |
56 | /**
57 | * Get file histogram
58 | *
59 | * @return histogram
60 | */
61 | public FileHistogram getHistogram() {
62 | return histogram;
63 | }
64 |
65 | @Override
66 | public boolean include(final RevCommit commit,
67 | final Collection diffs) {
68 | for (DiffEntry diff : diffs)
69 | histogram.include(commit, diff);
70 | return true;
71 | }
72 |
73 | @Override
74 | public CommitFilter reset() {
75 | histogram = new FileHistogram();
76 | return super.reset();
77 | }
78 |
79 | @Override
80 | public RevFilter clone() {
81 | return new FileHistogramFilter(detectRenames);
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/stat/LatestComparator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.stat;
23 |
24 | import java.io.Serializable;
25 | import java.util.Comparator;
26 |
27 | /**
28 | * Comparator that sorts by latest user activity first
29 | */
30 | public class LatestComparator implements Comparator,
31 | Serializable {
32 |
33 | /** serialVersionUID */
34 | private static final long serialVersionUID = -1188908635265244096L;
35 |
36 | public int compare(final UserCommitActivity u1, final UserCommitActivity u2) {
37 | final long l1 = u1.getLatest();
38 | final long l2 = u2.getLatest();
39 | if (l1 > l2)
40 | return -1;
41 | if (l1 < l2)
42 | return 1;
43 | return 0;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/stat/Month.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.stat;
23 |
24 | import java.util.Locale;
25 |
26 | /**
27 | * Months with number of days and indices
28 | */
29 | public enum Month {
30 |
31 | /** JANUARY */
32 | JANUARY(0, 31),
33 |
34 | /** FEBRUARY */
35 | FEBRUARY(1, 29),
36 |
37 | /** MARCH */
38 | MARCH(2, 31),
39 |
40 | /** APRIL */
41 | APRIL(3, 30),
42 |
43 | /** MAY */
44 | MAY(4, 31),
45 |
46 | /** JUNE */
47 | JUNE(5, 30),
48 |
49 | /** JULY */
50 | JULY(6, 31),
51 |
52 | /** AUGUST */
53 | AUGUST(7, 31),
54 |
55 | /** SEPTEMBER */
56 | SEPTEMBER(8, 30),
57 |
58 | /** OCTOBER */
59 | OCTOBER(9, 31),
60 |
61 | /** NOVEMBER */
62 | NOVEMBER(10, 30),
63 |
64 | /** DECEMBER */
65 | DECEMBER(11, 31);
66 |
67 | /**
68 | * Month number
69 | */
70 | public final int number;
71 |
72 | /**
73 | * Days in month
74 | */
75 | public final int days;
76 |
77 | /**
78 | * Get month for given number
79 | *
80 | * @param number
81 | * @return month
82 | */
83 | public static Month month(final int number) {
84 | switch (number) {
85 | case 0:
86 | return JANUARY;
87 | case 1:
88 | return FEBRUARY;
89 | case 2:
90 | return MARCH;
91 | case 3:
92 | return APRIL;
93 | case 4:
94 | return MAY;
95 | case 5:
96 | return JUNE;
97 | case 6:
98 | return JULY;
99 | case 7:
100 | return AUGUST;
101 | case 8:
102 | return SEPTEMBER;
103 | case 9:
104 | return OCTOBER;
105 | case 10:
106 | return NOVEMBER;
107 | case 11:
108 | return DECEMBER;
109 | default:
110 | return null;
111 | }
112 | }
113 |
114 | Month(final int number, final int days) {
115 | this.number = number;
116 | this.days = days;
117 | }
118 |
119 | public String toString() {
120 | final String name = name();
121 | return name.substring(0, 1) + name.substring(1).toLowerCase(Locale.US);
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/org.gitective.core/src/main/java/org/gitective/core/stat/RevisionCountComparator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.core.stat;
23 |
24 | import java.io.Serializable;
25 | import java.util.Comparator;
26 |
27 | /**
28 | * Comparator that sorts by descending number of revisions
29 | */
30 | public class RevisionCountComparator implements Comparator,
31 | Serializable {
32 |
33 | /** serialVersionUID */
34 | private static final long serialVersionUID = 3211628170171642223L;
35 |
36 | public int compare(final FileCommitActivity f1, final FileCommitActivity f2) {
37 | final int r1 = f1.getRevisions();
38 | final int r2 = f2.getRevisions();
39 | if (r1 > r2)
40 | return -1;
41 | if (r1 < r2)
42 | return 1;
43 | return 0;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/org.gitective.core/src/site/resources/CNAME:
--------------------------------------------------------------------------------
1 | gitective.org
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/AndTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import org.eclipse.jgit.revwalk.filter.RevFilter;
25 | import org.gitective.core.filter.commit.AndCommitFilter;
26 | import org.gitective.core.filter.commit.CommitLimitFilter;
27 | import org.junit.Test;
28 |
29 | /**
30 | * Unit tests of {@link AndCommitFilter}
31 | */
32 | public class AndTest extends GitTestCase {
33 |
34 | /**
35 | * Unit test of {@link AndCommitFilter#clone()}
36 | */
37 | @Test
38 | public void cloneFilter() {
39 | CommitLimitFilter limit = new CommitLimitFilter(1);
40 | AndCommitFilter and = new AndCommitFilter(limit);
41 | RevFilter clone = and.clone();
42 | assertNotNull(clone);
43 | assertNotSame(and, clone);
44 | assertTrue(clone instanceof AndCommitFilter);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/BadRefDatabase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import java.io.IOException;
25 | import java.util.List;
26 | import java.util.Map;
27 |
28 | import org.eclipse.jgit.lib.Ref;
29 | import org.eclipse.jgit.lib.RefDatabase;
30 | import org.eclipse.jgit.lib.RefRename;
31 | import org.eclipse.jgit.lib.RefUpdate;
32 |
33 | /**
34 | * Ref database that throwns the same exception on every call
35 | */
36 | public class BadRefDatabase extends RefDatabase {
37 |
38 | private final IOException exception;
39 |
40 | /**
41 | * Create bad ref database
42 | *
43 | * @param exception
44 | */
45 | public BadRefDatabase(IOException exception) {
46 | this.exception = exception;
47 | }
48 |
49 | public void create() throws IOException {
50 | throw exception;
51 | }
52 |
53 | public void close() {
54 | }
55 |
56 | public boolean isNameConflicting(String name) throws IOException {
57 | throw exception;
58 | }
59 |
60 | public RefUpdate newUpdate(String name, boolean detach) throws IOException {
61 | throw exception;
62 | }
63 |
64 | public RefRename newRename(String fromName, String toName)
65 | throws IOException {
66 | throw exception;
67 | }
68 |
69 | public Ref getRef(String name) throws IOException {
70 | throw exception;
71 | }
72 |
73 | public Map getRefs(String prefix) throws IOException {
74 | throw exception;
75 | }
76 |
77 | public List[ getAdditionalRefs() throws IOException {
78 | throw exception;
79 | }
80 |
81 | public Ref peel(Ref ref) throws IOException {
82 | throw exception;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/BadRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import java.io.File;
25 | import java.io.IOException;
26 |
27 | import org.eclipse.jgit.lib.BaseRepositoryBuilder;
28 | import org.eclipse.jgit.lib.RefDatabase;
29 | import org.eclipse.jgit.storage.file.FileRepository;
30 |
31 | /**
32 | * Repository that has a bad ref database
33 | */
34 | public class BadRepository extends FileRepository {
35 |
36 | private final BadRefDatabase db;
37 |
38 | /**
39 | * @param options
40 | * @param exception
41 | * @throws IOException
42 | */
43 | public BadRepository(
44 | @SuppressWarnings("rawtypes") BaseRepositoryBuilder options,
45 | IOException exception) throws IOException {
46 | super(options);
47 | db = new BadRefDatabase(exception);
48 | }
49 |
50 | /**
51 | * @param gitDir
52 | * @param exception
53 | * @throws IOException
54 | */
55 | public BadRepository(File gitDir, IOException exception) throws IOException {
56 | super(gitDir);
57 | db = new BadRefDatabase(exception);
58 | }
59 |
60 | /**
61 | * @param gitDir
62 | * @param exception
63 | * @throws IOException
64 | */
65 | public BadRepository(String gitDir, IOException exception)
66 | throws IOException {
67 | super(gitDir);
68 | db = new BadRefDatabase(exception);
69 | }
70 |
71 | public RefDatabase getRefDatabase() {
72 | return db;
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/BranchTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import org.eclipse.jgit.revwalk.RevCommit;
25 | import org.gitective.core.CommitFinder;
26 | import org.gitective.core.filter.commit.CommitListFilter;
27 | import org.junit.Test;
28 |
29 | /**
30 | * Unit tests of working with branches
31 | */
32 | public class BranchTest extends GitTestCase {
33 |
34 | /**
35 | * Test finding commits in all branches
36 | *
37 | * @throws Exception
38 | */
39 | @Test
40 | public void branches() throws Exception {
41 | RevCommit masterCommit = add("f0.txt", "content0");
42 | branch("b1");
43 | RevCommit b1Commit = add("f1.txt", "content1");
44 | branch("b2");
45 | RevCommit b2Commit = add("f2.txt", "content2");
46 |
47 | CommitFinder finder = new CommitFinder(testRepo);
48 | CommitListFilter commits = new CommitListFilter();
49 | finder.setFilter(commits).findInBranches();
50 | assertTrue(commits.getCommits().contains(masterCommit));
51 | assertTrue(commits.getCommits().contains(b1Commit));
52 | assertTrue(commits.getCommits().contains(b2Commit));
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/ChangeIdTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import org.gitective.core.CommitFinder;
25 | import org.gitective.core.filter.commit.AndCommitFilter;
26 | import org.gitective.core.filter.commit.ChangeIdFilter;
27 | import org.gitective.core.filter.commit.CommitCountFilter;
28 | import org.junit.Test;
29 |
30 | /**
31 | * Unit tests of {@link ChangeIdFilter}
32 | */
33 | public class ChangeIdTest extends GitTestCase {
34 |
35 | /**
36 | * Test match
37 | *
38 | * @throws Exception
39 | */
40 | @Test
41 | public void match() throws Exception {
42 | add("file.txt", "patch",
43 | "fixes a bug\nChange-Id: I12345abcde12345abcde12345abcde12345abcde");
44 |
45 | CommitFinder service = new CommitFinder(testRepo);
46 | CommitCountFilter count = new CommitCountFilter();
47 | service.setFilter(new AndCommitFilter(new ChangeIdFilter(), count));
48 | service.find();
49 | assertEquals(1, count.getCount());
50 |
51 | service.setFilter(new AndCommitFilter(new ChangeIdFilter().clone(),
52 | count));
53 | service.find();
54 | assertEquals(2, count.getCount());
55 | }
56 |
57 | /**
58 | * Test non-match
59 | *
60 | * @throws Exception
61 | */
62 | @Test
63 | public void nonMatch() throws Exception {
64 | add("file.txt", "patch",
65 | "fixes a bug\nChange-Id: I12345abcde12345abxyz12345abcde12345abcde");
66 |
67 | CommitFinder service = new CommitFinder(testRepo);
68 | CommitCountFilter count = new CommitCountFilter();
69 | service.setFilter(new AndCommitFilter(new ChangeIdFilter(), count));
70 | service.find();
71 | assertEquals(0, count.getCount());
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/CheckTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import org.gitective.core.Check;
25 | import org.junit.Assert;
26 | import org.junit.Test;
27 |
28 | /**
29 | * Unit tests of {@link Check} class
30 | */
31 | public class CheckTest extends Assert {
32 |
33 | /**
34 | * Test {@link Check} class constructor
35 | */
36 | @Test
37 | public void contructor() {
38 | assertNotNull(new Check() {
39 | });
40 | }
41 |
42 | /**
43 | * Unit test of {@link Check#anyNull(Object...)}
44 | */
45 | @Test
46 | public void anyNull() {
47 | assertTrue(Check.anyNull((Object) null));
48 | assertFalse(Check.anyNull(this));
49 | assertTrue(Check.anyNull("", (Object) null));
50 | }
51 |
52 | /**
53 | * Unit test of {@link Check#allNull(Object...)}
54 | */
55 | @Test
56 | public void allNull() {
57 | assertTrue(Check.allNull((Object) null));
58 | assertFalse(Check.allNull(this));
59 | assertFalse(Check.allNull("", (Object) null));
60 | }
61 |
62 | /**
63 | * Unit test of {@link Check#equals(Object)}
64 | */
65 | @Test
66 | public void equals() {
67 | assertTrue(Check.equals(null, null));
68 | assertFalse(Check.equals("a", null));
69 | assertFalse(Check.equals(null, "b"));
70 | assertFalse(Check.equals("a", "b"));
71 | assertTrue(Check.equals("a", "a"));
72 | }
73 |
74 | /**
75 | * Unit test of {@link Check#equalsNonNull(Object, Object)}
76 | */
77 | @Test
78 | public void equalsNonNull() {
79 | assertFalse(Check.equalsNonNull(null, null));
80 | assertFalse(Check.equalsNonNull("a", "b"));
81 | assertTrue(Check.equalsNonNull("a", "a"));
82 | }
83 |
84 | /**
85 | * Test all null with null objects
86 | */
87 | @Test(expected = IllegalArgumentException.class)
88 | public void allNullWithNull() {
89 | Check.allNull((Object[]) null);
90 | }
91 |
92 | /**
93 | * Test any null with null objects
94 | */
95 | @Test(expected = IllegalArgumentException.class)
96 | public void anyNullWithNull() {
97 | Check.anyNull((Object[]) null);
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/CommitBaseTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import org.eclipse.jgit.lib.Constants;
25 | import org.eclipse.jgit.lib.Repository;
26 | import org.eclipse.jgit.revwalk.RevCommit;
27 | import org.eclipse.jgit.storage.file.FileRepository;
28 | import org.gitective.core.CommitFinder;
29 | import org.gitective.core.CommitUtils;
30 | import org.gitective.core.filter.commit.CommitListFilter;
31 | import org.junit.Test;
32 |
33 | /**
34 | * Tests of
35 | * {@link CommitUtils#getBase(Repository, org.eclipse.jgit.lib.ObjectId...)} and
36 | * {@link CommitUtils#getBase(Repository, String...)}
37 | */
38 | public class CommitBaseTest extends GitTestCase {
39 |
40 | /**
41 | * Test getting the base commit of a branch and master and then walking
42 | * between the tip of the branch and its branch point.
43 | *
44 | * @throws Exception
45 | */
46 | @Test
47 | public void baseCommits() throws Exception {
48 | RevCommit commit1 = add("file.txt", "content");
49 | branch("release1");
50 | RevCommit commit2 = add("file.txt", "edit 1");
51 | RevCommit commit3 = add("file.txt", "edit 2");
52 |
53 | Repository repo = new FileRepository(testRepo);
54 | RevCommit base = CommitUtils
55 | .getBase(repo, Constants.MASTER, "release1");
56 | assertEquals(commit1, base);
57 |
58 | RevCommit base2 = CommitUtils.getBase(repo,
59 | CommitUtils.getCommit(repo, Constants.MASTER),
60 | CommitUtils.getCommit(repo, "release1"));
61 | assertEquals(base, base2);
62 |
63 | CommitListFilter filter = new CommitListFilter();
64 | new CommitFinder(testRepo).setFilter(filter).findBetween(commit3, base);
65 | assertEquals(2, filter.getCommits().size());
66 | assertEquals(commit3, filter.getCommits().get(0));
67 | assertEquals(commit2, filter.getCommits().get(1));
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/CommitImpactTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import org.eclipse.jgit.revwalk.RevCommit;
25 | import org.gitective.core.filter.commit.CommitImpact;
26 | import org.junit.Test;
27 |
28 | /**
29 | * Unit tests of {@link CommitImpactTest}
30 | */
31 | public class CommitImpactTest extends GitTestCase {
32 |
33 | /**
34 | * Validate {@link CommitImpact}
35 | *
36 | * @throws Exception
37 | */
38 | @Test
39 | public void commitImpact() throws Exception {
40 | RevCommit commit = add("test.txt", "content");
41 | CommitImpact impact = new CommitImpact(commit, 1, 2, 3);
42 | assertEquals(commit, impact.getCommit());
43 | assertEquals(1, impact.getAdd());
44 | assertEquals(2, impact.getEdit());
45 | assertEquals(3, impact.getDelete());
46 | assertTrue(impact.equals(impact));
47 | assertFalse(impact.equals(""));
48 |
49 | CommitImpact same = new CommitImpact(commit, 1, 2, 3);
50 | assertEquals(impact, same);
51 | assertEquals(impact.hashCode(), same.hashCode());
52 | assertEquals(impact.toString(), same.toString());
53 |
54 | CommitImpact different = new CommitImpact(commit, 1, 2, 4);
55 | assertFalse(impact.equals(different));
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/CommitListTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import org.eclipse.jgit.revwalk.RevCommit;
25 | import org.eclipse.jgit.revwalk.filter.RevFilter;
26 | import org.gitective.core.CommitFinder;
27 | import org.gitective.core.filter.commit.CommitListFilter;
28 | import org.junit.Test;
29 |
30 | /**
31 | * Unit tests of {@link CommitListFilter}
32 | */
33 | public class CommitListTest extends GitTestCase {
34 |
35 | /**
36 | * Unit test of {@link CommitListFilter#clone()}
37 | */
38 | @Test
39 | public void cloneFilter() {
40 | CommitListFilter filter = new CommitListFilter();
41 | assertTrue(filter.getCommits().isEmpty());
42 | RevFilter clone = filter.clone();
43 | assertNotNull(clone);
44 | assertNotSame(filter, clone);
45 | assertTrue(clone instanceof CommitListFilter);
46 | assertTrue(((CommitListFilter) clone).getCommits().isEmpty());
47 | }
48 |
49 | /**
50 | * Unit test of {@link CommitListFilter#reset()}
51 | *
52 | * @throws Exception
53 | */
54 | @Test
55 | public void reset() throws Exception {
56 | RevCommit commit = add("file.txt", "content");
57 |
58 | CommitListFilter filter = new CommitListFilter();
59 | CommitFinder service = new CommitFinder(testRepo);
60 | service.setFilter(filter);
61 | service.find();
62 |
63 | assertFalse(filter.getCommits().isEmpty());
64 | assertEquals(1, filter.getCommits().size());
65 | assertEquals(commit, filter.getCommits().get(0));
66 |
67 | filter.reset();
68 |
69 | assertTrue(filter.getCommits().isEmpty());
70 |
71 | service.find();
72 |
73 | assertFalse(filter.getCommits().isEmpty());
74 | assertEquals(1, filter.getCommits().size());
75 | assertEquals(commit, filter.getCommits().get(0));
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/CommitterDiffFilterTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import org.eclipse.jgit.lib.PersonIdent;
25 | import org.eclipse.jgit.revwalk.filter.RevFilter;
26 | import org.gitective.core.CommitFinder;
27 | import org.gitective.core.filter.commit.AndCommitFilter;
28 | import org.gitective.core.filter.commit.CommitCountFilter;
29 | import org.gitective.core.filter.commit.CommitterDiffFilter;
30 | import org.junit.Test;
31 |
32 | /**
33 | * Unit tests of {@link CommitterDiffFilter}
34 | */
35 | public class CommitterDiffFilterTest extends GitTestCase {
36 |
37 | /**
38 | * Verify a filter on a repository with no commits that have differing
39 | * authors and committers in the same commit
40 | *
41 | * @throws Exception
42 | */
43 | @Test
44 | public void samePersons() throws Exception {
45 | committer = author;
46 | add("file.txt", "a");
47 | add("file.txt", "b");
48 | CommitterDiffFilter filter = new CommitterDiffFilter();
49 | CommitCountFilter count = new CommitCountFilter();
50 | new CommitFinder(testRepo)
51 | .setFilter(new AndCommitFilter(filter, count)).find();
52 | assertEquals(0, count.getCount());
53 | }
54 |
55 | /**
56 | * Verify a filter on a repository with a single commit where the author and
57 | * committer differ
58 | *
59 | * @throws Exception
60 | */
61 | @Test
62 | public void singleDiffPersonCommit() throws Exception {
63 | committer = author;
64 | add("file.txt", "a");
65 | committer = new PersonIdent("Name" + System.nanoTime(), "Email"
66 | + System.nanoTime());
67 | add("file.txt", "b");
68 | CommitterDiffFilter filter = new CommitterDiffFilter();
69 | CommitCountFilter count = new CommitCountFilter();
70 | new CommitFinder(testRepo)
71 | .setFilter(new AndCommitFilter(filter, count)).find();
72 | assertEquals(1, count.getCount());
73 | }
74 |
75 | /**
76 | * Verify filter clones
77 | */
78 | @Test
79 | public void cloneFilter() {
80 | CommitterDiffFilter filter = new CommitterDiffFilter();
81 | RevFilter clone = filter.clone();
82 | assertNotNull(clone);
83 | assertNotSame(filter, clone);
84 | assertTrue(clone instanceof CommitterDiffFilter);
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/CountTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import org.eclipse.jgit.revwalk.filter.RevFilter;
25 | import org.gitective.core.filter.commit.CommitCountFilter;
26 | import org.gitective.core.filter.commit.CommitListFilter;
27 | import org.junit.Test;
28 |
29 | /**
30 | * Unit tests of {@link CommitCountFilter}
31 | */
32 | public class CountTest extends GitTestCase {
33 |
34 | /**
35 | * Unit test of {@link CommitListFilter#clone()}
36 | */
37 | @Test
38 | public void cloneFilter() {
39 | CommitCountFilter filter = new CommitCountFilter();
40 | assertEquals(0, filter.getCount());
41 | RevFilter clone = filter.clone();
42 | assertNotNull(clone);
43 | assertNotSame(filter, clone);
44 | assertTrue(clone instanceof CommitCountFilter);
45 | assertEquals(0, ((CommitCountFilter) clone).getCount());
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/DiffCountTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import java.util.ArrayList;
25 | import java.util.Collection;
26 | import java.util.List;
27 |
28 | import org.eclipse.jgit.diff.DiffEntry;
29 | import org.eclipse.jgit.revwalk.RevCommit;
30 | import org.eclipse.jgit.revwalk.filter.RevFilter;
31 | import org.gitective.core.CommitFinder;
32 | import org.gitective.core.filter.commit.DiffCountFilter;
33 | import org.junit.Test;
34 |
35 | /**
36 | * Unit tests of {@link DiffCountFilter}
37 | */
38 | public class DiffCountTest extends GitTestCase {
39 |
40 | /**
41 | * Test default filter
42 | *
43 | * @throws Exception
44 | */
45 | @Test
46 | public void defaultFilter() throws Exception {
47 | add("file.txt", "a\nb\nc");
48 | DiffCountFilter filter = new DiffCountFilter();
49 | filter.setStop(true);
50 | new CommitFinder(testRepo).setFilter(filter).find();
51 | }
52 |
53 | /**
54 | * Test {@link DiffCountFilter#clone()}
55 | *
56 | * @throws Exception
57 | */
58 | @Test
59 | public void cloneFilter() throws Exception {
60 | DiffCountFilter filter1 = new DiffCountFilter();
61 | RevFilter filter2 = filter1.clone();
62 | assertNotNull(filter2);
63 | assertTrue(filter2 instanceof DiffCountFilter);
64 | assertNotSame(filter1, filter2);
65 | }
66 |
67 | /**
68 | * Test counting diffs
69 | *
70 | * @throws Exception
71 | */
72 | @Test
73 | public void diffSingleFile() throws Exception {
74 | add("file.txt", "a\nb\nc");
75 | add("file.txt", "a\nb2\nc");
76 | add("file.txt", "");
77 | final List counts = new ArrayList();
78 | DiffCountFilter filter = new DiffCountFilter() {
79 |
80 | protected boolean include(RevCommit commit,
81 | Collection diffs, int diffCount) {
82 | counts.add(0, diffCount);
83 | return true;
84 | }
85 |
86 | };
87 | new CommitFinder(testRepo).setFilter(filter).find();
88 | assertEquals(3, counts.size());
89 | assertEquals(3, counts.get(0).intValue());
90 | assertEquals(1, counts.get(1).intValue());
91 | assertEquals(3, counts.get(2).intValue());
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/EarliestComparatorTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import java.util.Date;
25 | import java.util.TimeZone;
26 |
27 | import org.eclipse.jgit.lib.PersonIdent;
28 | import org.eclipse.jgit.revwalk.RevCommit;
29 | import org.gitective.core.stat.EarliestComparator;
30 | import org.gitective.core.stat.UserCommitActivity;
31 | import org.junit.Test;
32 |
33 | /**
34 | * Unit tests of {@link EarliestComparatorTest}
35 | */
36 | public class EarliestComparatorTest extends GitTestCase {
37 |
38 | /**
39 | * Test comparing user activity
40 | *
41 | * @throws Exception
42 | */
43 | @Test
44 | public void compare() throws Exception {
45 | RevCommit commit = add("test.txt", "content");
46 |
47 | UserCommitActivity user1 = new UserCommitActivity("a", "b");
48 | UserCommitActivity user2 = new UserCommitActivity("c", "d");
49 |
50 | user1.include(commit, new PersonIdent("a", "b", new Date(1000),
51 | TimeZone.getDefault()));
52 |
53 | user2.include(commit, new PersonIdent("b", "c", new Date(2000),
54 | TimeZone.getDefault()));
55 |
56 | EarliestComparator comparator = new EarliestComparator();
57 | assertEquals(0, comparator.compare(user1, user1));
58 | assertEquals(0, comparator.compare(user2, user2));
59 | assertTrue(comparator.compare(user1, user2) < 0);
60 | assertTrue(comparator.compare(user2, user1) > 0);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/GitExceptionTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import java.io.IOException;
25 |
26 | import org.eclipse.jgit.storage.file.FileRepository;
27 | import org.gitective.core.GitException;
28 | import org.junit.Test;
29 |
30 | /**
31 | * Unit tests of {@link GitException}
32 | */
33 | public class GitExceptionTest extends GitTestCase {
34 |
35 | /**
36 | * Test constructors
37 | *
38 | * @throws IOException
39 | */
40 | @Test
41 | public void constructors() throws IOException {
42 | String message = "test";
43 | NullPointerException cause = new NullPointerException();
44 | FileRepository repo = new FileRepository(testRepo);
45 |
46 | GitException exception = new GitException(message, repo);
47 | assertEquals(repo, exception.getRepository());
48 | assertEquals(message, exception.getMessage());
49 |
50 | exception = new GitException(message, cause, repo);
51 | assertEquals(repo, exception.getRepository());
52 | assertEquals(cause, exception.getCause());
53 | assertEquals(message, exception.getMessage());
54 |
55 | exception = new GitException(repo);
56 | assertEquals(repo, exception.getRepository());
57 | assertNull(exception.getCause());
58 | assertNull(exception.getMessage());
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/LastTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import org.eclipse.jgit.revwalk.RevCommit;
25 | import org.eclipse.jgit.revwalk.filter.RevFilter;
26 | import org.gitective.core.CommitFinder;
27 | import org.gitective.core.filter.commit.AndCommitFilter;
28 | import org.gitective.core.filter.commit.CommitLimitFilter;
29 | import org.gitective.core.filter.commit.LastCommitFilter;
30 | import org.junit.Test;
31 |
32 | /**
33 | * Unit tests of {@link LastCommitFilter}
34 | */
35 | public class LastTest extends GitTestCase {
36 |
37 | /**
38 | * Test storing last commit visited
39 | *
40 | * @throws Exception
41 | */
42 | @Test
43 | public void last() throws Exception {
44 | add("a.txt", "a");
45 | RevCommit commit2 = add("a.txt", "b");
46 | add("a.txt", "c");
47 |
48 | LastCommitFilter last = new LastCommitFilter();
49 | assertNull(last.getLast());
50 | CommitLimitFilter limit = new CommitLimitFilter(2);
51 | AndCommitFilter filter = new AndCommitFilter(limit, last);
52 | CommitFinder finder = new CommitFinder(testRepo);
53 | finder.setFilter(filter);
54 | finder.find();
55 | assertEquals(commit2, last.getLast());
56 | finder.find();
57 | assertEquals(commit2, last.getLast());
58 | last.reset();
59 | assertNull(last.getLast());
60 | limit.reset();
61 | finder.find();
62 | assertEquals(commit2, last.getLast());
63 | }
64 |
65 | /**
66 | * Test of {@link LastCommitFilter#clone()}
67 | */
68 | @Test
69 | public void cloneFilter() {
70 | LastCommitFilter filter = new LastCommitFilter();
71 | assertNull(filter.getLast());
72 | RevFilter clone = filter.clone();
73 | assertNotNull(clone);
74 | assertNotSame(filter, clone);
75 | assertTrue(clone instanceof LastCommitFilter);
76 | assertNull(((LastCommitFilter) clone).getLast());
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/LatestComparatorTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import java.util.Date;
25 | import java.util.TimeZone;
26 |
27 | import org.eclipse.jgit.lib.PersonIdent;
28 | import org.eclipse.jgit.revwalk.RevCommit;
29 | import org.gitective.core.stat.LatestComparator;
30 | import org.gitective.core.stat.UserCommitActivity;
31 | import org.junit.Test;
32 |
33 | /**
34 | * Unit tests of {@link LatestComparatorTest}
35 | */
36 | public class LatestComparatorTest extends GitTestCase {
37 |
38 | /**
39 | * Test comparing user activity
40 | *
41 | * @throws Exception
42 | */
43 | @Test
44 | public void compare() throws Exception {
45 | RevCommit commit = add("test.txt", "content");
46 |
47 | UserCommitActivity user1 = new UserCommitActivity("a", "b");
48 | UserCommitActivity user2 = new UserCommitActivity("c", "d");
49 |
50 | user1.include(commit, new PersonIdent("a", "b", new Date(1000),
51 | TimeZone.getDefault()));
52 |
53 | user2.include(commit, new PersonIdent("b", "c", new Date(2000),
54 | TimeZone.getDefault()));
55 |
56 | LatestComparator comparator = new LatestComparator();
57 | assertEquals(0, comparator.compare(user1, user1));
58 | assertEquals(0, comparator.compare(user2, user2));
59 | assertTrue(comparator.compare(user2, user1) < 0);
60 | assertTrue(comparator.compare(user1, user2) > 0);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/LatestTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import org.eclipse.jgit.revwalk.RevCommit;
25 | import org.eclipse.jgit.storage.file.FileRepository;
26 | import org.gitective.core.CommitUtils;
27 | import org.junit.Test;
28 |
29 | /**
30 | * Unit tests of {@link CommitUtils#getHead(org.eclipse.jgit.lib.Repository)}
31 | */
32 | public class LatestTest extends GitTestCase {
33 |
34 | /**
35 | * Test retrieving latest commit from repository
36 | *
37 | * @throws Exception
38 | */
39 | @Test
40 | public void latest() throws Exception {
41 | RevCommit commit = add("file.txt", "content");
42 | assertEquals(commit, CommitUtils.getHead(new FileRepository(testRepo)));
43 | assertEquals(commit,
44 | CommitUtils.getMaster(new FileRepository(testRepo)));
45 | }
46 |
47 | /**
48 | * Test retrieving latest commit from repository
49 | *
50 | * @throws Exception
51 | */
52 | public void latestOnEmptyRepository() throws Exception {
53 | assertNull(CommitUtils.getHead(new FileRepository(testRepo)));
54 | }
55 |
56 | /**
57 | * Test lookup of commit by id
58 | *
59 | * @throws Exception
60 | */
61 | @Test
62 | public void byId() throws Exception {
63 | RevCommit commit = add("file.txt", "content");
64 | assertEquals(commit,
65 | CommitUtils.getCommit(new FileRepository(testRepo), commit));
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/MonthTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import org.gitective.core.stat.Month;
25 | import org.junit.Test;
26 |
27 | import junit.framework.Assert;
28 |
29 | /**
30 | * Unit test of {@link Month} enum
31 | */
32 | public class MonthTest extends Assert {
33 |
34 | /**
35 | * Test month values
36 | */
37 | @Test
38 | public void monthValues() {
39 | assertNull(Month.month(-1));
40 | for (Month month : Month.values()) {
41 | assertNotNull(month);
42 | assertTrue(month.number >= 0);
43 | assertTrue(month.days > 0);
44 | assertEquals(month, Month.month(month.number));
45 | assertNotNull(month.toString());
46 | assertTrue(month.toString().length() > 0);
47 | assertEquals(month, Month.valueOf(month.name()));
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/MultiRepoTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import java.io.File;
25 |
26 | import org.eclipse.jgit.revwalk.RevCommit;
27 | import org.eclipse.jgit.storage.file.FileRepository;
28 | import org.gitective.core.CommitFinder;
29 | import org.gitective.core.filter.commit.CommitCountFilter;
30 | import org.junit.Test;
31 |
32 | /**
33 | * Unit tests of using multiple repositories from the same service class.
34 | */
35 | public class MultiRepoTest extends GitTestCase {
36 |
37 | /**
38 | * Test service constructors
39 | *
40 | * @throws Exception
41 | */
42 | @Test
43 | public void constructors() throws Exception {
44 | new CommitFinder(testRepo);
45 | new CommitFinder(new FileRepository(testRepo));
46 | new CommitFinder(testRepo.getAbsolutePath());
47 | }
48 |
49 | /**
50 | * Test search two repos from same service
51 | *
52 | * @throws Exception
53 | */
54 | @Test
55 | public void twoRepos() throws Exception {
56 | add("repo1file.txt", "content");
57 | File repo2 = initRepo();
58 | RevCommit repo2Commit = add(repo2, "repo2file.txt", "test");
59 | assertEquals(0, repo2Commit.getParentCount());
60 |
61 | CommitFinder service = new CommitFinder(testRepo, repo2);
62 | CommitCountFilter count = new CommitCountFilter();
63 | service.setFilter(count).find();
64 | assertEquals(2, count.getCount());
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/OrTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import org.eclipse.jgit.revwalk.filter.RevFilter;
25 | import org.gitective.core.CommitFinder;
26 | import org.gitective.core.filter.commit.AndCommitFilter;
27 | import org.gitective.core.filter.commit.CommitCountFilter;
28 | import org.gitective.core.filter.commit.CommitLimitFilter;
29 | import org.gitective.core.filter.commit.OrCommitFilter;
30 | import org.junit.Test;
31 |
32 | /**
33 | * Unit tests of {@link OrCommitFilter}
34 | */
35 | public class OrTest extends GitTestCase {
36 |
37 | /**
38 | * Test of {@link OrCommitFilter#clone()}
39 | */
40 | @Test
41 | public void cloneFilter() {
42 | CommitCountFilter count = new CommitCountFilter();
43 | OrCommitFilter or = new OrCommitFilter(count);
44 | RevFilter clone = or.clone();
45 | assertNotNull(clone);
46 | assertNotSame(or, clone);
47 | assertTrue(clone instanceof OrCommitFilter);
48 | }
49 |
50 | /**
51 | * Test second filter in a {@link OrCommitFilter} not being called when the
52 | * first filter matches.
53 | *
54 | * @throws Exception
55 | */
56 | @Test
57 | public void secondNotCalled() throws Exception {
58 | add("file.txt", "test");
59 | add("file.txt", "testa");
60 | CommitLimitFilter limit = new CommitLimitFilter(1);
61 | CommitCountFilter count = new CommitCountFilter();
62 | CommitFinder service = new CommitFinder(testRepo);
63 | service.setFilter(new OrCommitFilter(limit, count)).find();
64 | assertEquals(1, count.getCount());
65 | }
66 |
67 | /**
68 | * Test no matches of the filters in an {@link OrCommitFilter}
69 | *
70 | * @throws Exception
71 | */
72 | @Test
73 | public void noMatches() throws Exception {
74 | add("file.txt", "test");
75 | add("file.txt", "testa");
76 | add("file.txt", "testb");
77 |
78 | CommitLimitFilter limit = new CommitLimitFilter(2);
79 | CommitCountFilter count = new CommitCountFilter();
80 | CommitFinder service = new CommitFinder(testRepo);
81 | service.setFilter(new AndCommitFilter(new OrCommitFilter().add(limit),
82 | count));
83 | service.find();
84 | assertEquals(2, count.getCount());
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/RepositoryServiceTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import java.io.File;
25 |
26 | import junit.framework.Assert;
27 |
28 | import org.eclipse.jgit.lib.Repository;
29 | import org.gitective.core.RepositoryService;
30 | import org.junit.Test;
31 |
32 | /**
33 | * Unit tests of {@link RepositoryService} class
34 | */
35 | public class RepositoryServiceTest extends Assert {
36 |
37 | /**
38 | * Test constructor with null repositories
39 | */
40 | @Test(expected = IllegalArgumentException.class)
41 | public void nullStringDirectories() {
42 | new RepositoryService((String[]) null);
43 | }
44 |
45 | /**
46 | * Test constructor with empty repositories
47 | */
48 | @Test(expected = IllegalArgumentException.class)
49 | public void emptyStringDirectories() {
50 | new RepositoryService(new String[0]);
51 | }
52 |
53 | /**
54 | * Test constructor with null repositories
55 | */
56 | @Test(expected = IllegalArgumentException.class)
57 | public void nullFileDirectories() {
58 | new RepositoryService((File[]) null);
59 | }
60 |
61 | /**
62 | * Test constructor with empty repositories
63 | */
64 | @Test(expected = IllegalArgumentException.class)
65 | public void emptyFileDirectories() {
66 | new RepositoryService(new File[0]);
67 | }
68 |
69 | /**
70 | * Test constructor with null repositories
71 | */
72 | @Test(expected = IllegalArgumentException.class)
73 | public void nullRepositories() {
74 | new RepositoryService((Repository[]) null);
75 | }
76 |
77 | /**
78 | * Test constructor with empty repositories
79 | */
80 | @Test(expected = IllegalArgumentException.class)
81 | public void emptyRepositories() {
82 | new RepositoryService(new Repository[0]);
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/SignedOffByTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import org.eclipse.jgit.lib.Constants;
25 | import org.eclipse.jgit.lib.PersonIdent;
26 | import org.gitective.core.CommitFinder;
27 | import org.gitective.core.filter.commit.AndCommitFilter;
28 | import org.gitective.core.filter.commit.CommitCountFilter;
29 | import org.gitective.core.filter.commit.SignedOffByFilter;
30 | import org.junit.Test;
31 |
32 | /**
33 | * Unit tests of {@link SignedOffByFilter}
34 | */
35 | public class SignedOffByTest extends GitTestCase {
36 |
37 | /**
38 | * Test match
39 | *
40 | * @throws Exception
41 | */
42 | @Test
43 | public void match() throws Exception {
44 | PersonIdent person = new PersonIdent("Test user", "test@user.com");
45 | add("file.txt", "patch", Constants.SIGNED_OFF_BY_TAG + person.getName()
46 | + " <" + person.getEmailAddress() + ">");
47 |
48 | CommitFinder service = new CommitFinder(testRepo);
49 | CommitCountFilter count = new CommitCountFilter();
50 | service.setFilter(new AndCommitFilter(new SignedOffByFilter(person),
51 | count));
52 | service.find();
53 | assertEquals(1, count.getCount());
54 |
55 | service.setFilter(new AndCommitFilter(new SignedOffByFilter(person)
56 | .clone(), count));
57 | service.find();
58 | assertEquals(2, count.getCount());
59 | }
60 |
61 | /**
62 | * Test non-match
63 | *
64 | * @throws Exception
65 | */
66 | @Test
67 | public void nonMatch() throws Exception {
68 | PersonIdent person = new PersonIdent("Test user", "test@user.com");
69 | add("file.txt", "patch", Constants.SIGNED_OFF_BY_TAG + "person");
70 |
71 | CommitFinder service = new CommitFinder(testRepo);
72 | CommitCountFilter count = new CommitCountFilter();
73 | service.setFilter(new AndCommitFilter(new SignedOffByFilter(person),
74 | count));
75 | service.find();
76 | assertEquals(0, count.getCount());
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/TagTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import org.eclipse.jgit.revwalk.RevCommit;
25 | import org.gitective.core.CommitFinder;
26 | import org.gitective.core.filter.commit.CommitListFilter;
27 | import org.junit.Test;
28 |
29 | /**
30 | * Unit tests of working with tags
31 | */
32 | public class TagTest extends GitTestCase {
33 |
34 | /**
35 | * Test finding commits in all tags
36 | *
37 | * @throws Exception
38 | */
39 | @Test
40 | public void tags() throws Exception {
41 | RevCommit commit1 = add("f1.txt", "content0");
42 | tag("t1");
43 | RevCommit commit2 = add("f2.txt", "content2");
44 |
45 | CommitFinder finder = new CommitFinder(testRepo);
46 | CommitListFilter commits = new CommitListFilter();
47 | finder.setFilter(commits).findInTags();
48 | assertTrue(commits.getCommits().contains(commit1));
49 | assertFalse(commits.getCommits().contains(commit2));
50 | }
51 |
52 | /**
53 | * Test searching for commits in repository with no tags
54 | *
55 | * @throws Exception
56 | */
57 | @Test
58 | public void noTags() throws Exception {
59 | RevCommit commit1 = add("f1.txt", "content0");
60 | CommitFinder finder = new CommitFinder(testRepo);
61 | CommitListFilter commits = new CommitListFilter();
62 | finder.setFilter(commits).findInTags();
63 | assertFalse(commits.getCommits().contains(commit1));
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/org.gitective.core/src/test/java/org/gitective/tests/TypeCountFilterTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011 Kevin Sawicki
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to
6 | * deal in the Software without restriction, including without limitation the
7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | * sell copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | * IN THE SOFTWARE.
21 | */
22 | package org.gitective.tests;
23 |
24 | import org.gitective.core.filter.tree.TypeCountFilter;
25 | import org.junit.Test;
26 |
27 | /**
28 | * Unit tests of {@link TypeCountFilter}
29 | */
30 | public class TypeCountFilterTest extends GitTestCase {
31 |
32 | /**
33 | * Test type filters
34 | *
35 | * @throws Exception
36 | */
37 | @Test
38 | public void typeFilters() throws Exception {
39 | assertNotNull(TypeCountFilter.file());
40 | assertNotNull(TypeCountFilter.submodule());
41 | assertNotNull(TypeCountFilter.symlink());
42 | assertNotNull(TypeCountFilter.tree());
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
]