| | |
| | | import org.eclipse.jgit.lib.ObjectLoader;
|
| | | import org.eclipse.jgit.lib.ObjectReader;
|
| | | import org.eclipse.jgit.lib.Repository;
|
| | | import org.eclipse.jgit.lib.RepositoryCache.FileKey;
|
| | | import org.eclipse.jgit.revwalk.RevCommit;
|
| | | import org.eclipse.jgit.revwalk.RevTree;
|
| | | import org.eclipse.jgit.revwalk.RevWalk;
|
| | |
| | | public class LuceneExecutor implements Runnable {
|
| | |
|
| | |
|
| | | private static final int INDEX_VERSION = 2;
|
| | | private static final int INDEX_VERSION = 3;
|
| | |
|
| | | private static final String FIELD_OBJECT_TYPE = "type";
|
| | | private static final String FIELD_ISSUE = "issue";
|
| | |
| | | String branch, RevCommit commit) {
|
| | | IndexResult result = new IndexResult();
|
| | | try {
|
| | | String [] encodings = storedSettings.getStrings(Keys.web.blobEncodings).toArray(new String[0]);
|
| | | List<PathChangeModel> changedPaths = JGitUtils.getFilesInCommit(repository, commit);
|
| | | String revDate = DateTools.timeToString(commit.getCommitTime() * 1000L,
|
| | | Resolution.MINUTE);
|
| | |
| | | if (StringUtils.isEmpty(ext) || !excludedExtensions.contains(ext)) {
|
| | | // read the blob content
|
| | | String str = JGitUtils.getStringContent(repository, commit.getTree(),
|
| | | path.path);
|
| | | path.path, encodings);
|
| | | doc.add(new Field(FIELD_CONTENT, str, Store.YES, Index.ANALYZED));
|
| | | writer.addDocument(doc);
|
| | | }
|
| | |
| | | * @throws IOException
|
| | | */
|
| | | private IndexWriter getIndexWriter(String repository) throws IOException {
|
| | | IndexWriter indexWriter = writers.get(repository); |
| | | File repositoryFolder = new File(repositoriesFolder, repository);
|
| | | IndexWriter indexWriter = writers.get(repository); |
| | | File repositoryFolder = FileKey.resolve(new File(repositoriesFolder, repository), FS.DETECTED);
|
| | | File indexFolder = new File(repositoryFolder, LUCENE_DIR);
|
| | | Directory directory = FSDirectory.open(indexFolder);
|
| | |
|
| | |
| | | return "<pre class=\"text\">" + StringUtils.escapeForHtml(fragment, true) + "</pre>";
|
| | | }
|
| | |
|
| | | int contentPos = 0;
|
| | | // make sure we have unique fragments
|
| | | Set<String> uniqueFragments = new LinkedHashSet<String>();
|
| | | for (String fragment : fragments) {
|
| | | uniqueFragments.add(fragment);
|
| | | }
|
| | | fragments = uniqueFragments.toArray(new String[uniqueFragments.size()]);
|
| | | |
| | | StringBuilder sb = new StringBuilder();
|
| | | for (int i = 0, len = fragments.length; i < len; i++) {
|
| | | String fragment = fragments[i];
|
| | |
| | | String raw = fragment.replace(termTag, "").replace(termTagEnd, "");
|
| | |
|
| | | // determine position of the raw fragment in the content
|
| | | int pos = content.indexOf(raw, contentPos);
|
| | | int pos = content.indexOf(raw);
|
| | |
|
| | | // restore complete first line of fragment
|
| | | int c = pos;
|
| | |
| | | }
|
| | | tag = MessageFormat.format("<pre class=\"prettyprint linenums:{0,number,0}{1}\">", line, lang);
|
| | |
|
| | | // update offset into content |
| | | contentPos = pos + raw.length() + 1;
|
| | | }
|
| | |
|
| | | sb.append(tag);
|