mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-02 03:25:56 +01:00
use person object for blame author informations
This commit is contained in:
@@ -56,18 +56,17 @@ public class BlameLine
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param emailAddress
|
||||
* @param name
|
||||
*
|
||||
* @param author
|
||||
* @param when
|
||||
* @param revision
|
||||
* @param code
|
||||
* @param lineNumber
|
||||
*/
|
||||
public BlameLine(String emailAddress, String name, Date when,
|
||||
String revision, String code, int lineNumber)
|
||||
public BlameLine(Person author, Date when, String revision, String code,
|
||||
int lineNumber)
|
||||
{
|
||||
this.emailAddress = emailAddress;
|
||||
this.name = name;
|
||||
this.author = author;
|
||||
this.when = when;
|
||||
this.revision = revision;
|
||||
this.code = code;
|
||||
@@ -76,6 +75,17 @@ public class BlameLine
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Person getAuthor()
|
||||
{
|
||||
return author;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -87,17 +97,6 @@ public class BlameLine
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getEmailAddress()
|
||||
{
|
||||
return emailAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -109,17 +108,6 @@ public class BlameLine
|
||||
return lineNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -144,6 +132,17 @@ public class BlameLine
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param author
|
||||
*/
|
||||
public void setAuthor(Person author)
|
||||
{
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -155,17 +154,6 @@ public class BlameLine
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param emailAddress
|
||||
*/
|
||||
public void setEmailAddress(String emailAddress)
|
||||
{
|
||||
this.emailAddress = emailAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -177,17 +165,6 @@ public class BlameLine
|
||||
this.lineNumber = lineNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -212,18 +189,15 @@ public class BlameLine
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private Person author;
|
||||
|
||||
/** Field description */
|
||||
private String code;
|
||||
|
||||
/** Field description */
|
||||
private String emailAddress;
|
||||
|
||||
/** Field description */
|
||||
private int lineNumber;
|
||||
|
||||
/** Field description */
|
||||
private String name;
|
||||
|
||||
/** Field description */
|
||||
private String revision;
|
||||
|
||||
|
||||
@@ -125,8 +125,8 @@ public class GitBlameViewer implements BlameViewer
|
||||
BlameLine blameLine = new BlameLine();
|
||||
|
||||
blameLine.setLineNumber(i);
|
||||
blameLine.setName(author.getName());
|
||||
blameLine.setEmailAddress(author.getEmailAddress());
|
||||
blameLine.setAuthor(new Person(author.getName(),
|
||||
author.getEmailAddress()));
|
||||
blameLine.setWhen(author.getWhen());
|
||||
|
||||
String rev = blameResult.getSourceCommit(i).getId().getName();
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
/**
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.repository;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.tmatesoft.svn.core.SVNException;
|
||||
import org.tmatesoft.svn.core.wc.ISVNAnnotateHandler;
|
||||
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class SvnBlameHandler implements ISVNAnnotateHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param blameLines
|
||||
*/
|
||||
public SvnBlameHandler(List<BlameLine> blameLines)
|
||||
{
|
||||
this.blameLines = blameLines;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void handleEOF()
|
||||
{
|
||||
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param date
|
||||
* @param revision
|
||||
* @param author
|
||||
* @param line
|
||||
*
|
||||
* @throws SVNException
|
||||
*/
|
||||
@Override
|
||||
public void handleLine(Date date, long revision, String author, String line)
|
||||
throws SVNException
|
||||
{
|
||||
handleLine(date, revision, author, line, null, -1, null, null, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param date
|
||||
* @param revision
|
||||
* @param author
|
||||
* @param line
|
||||
* @param mergedDate
|
||||
* @param mergedRevision
|
||||
* @param mergedAuthor
|
||||
* @param mergedPath
|
||||
* @param lineNumber
|
||||
*
|
||||
* @throws SVNException
|
||||
*/
|
||||
@Override
|
||||
public void handleLine(Date date, long revision, String author, String line,
|
||||
Date mergedDate, long mergedRevision,
|
||||
String mergedAuthor, String mergedPath, int lineNumber)
|
||||
throws SVNException
|
||||
{
|
||||
Person authorPerson = null;
|
||||
|
||||
if (Util.isNotEmpty(author))
|
||||
{
|
||||
authorPerson = new Person(author);
|
||||
}
|
||||
|
||||
blameLines.add(new BlameLine(authorPerson, date, String.valueOf(revision),
|
||||
line, lineNumber));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param date
|
||||
* @param revision
|
||||
* @param author
|
||||
* @param contents
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws SVNException
|
||||
*/
|
||||
@Override
|
||||
public boolean handleRevision(Date date, long revision, String author,
|
||||
File contents)
|
||||
throws SVNException
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private List<BlameLine> blameLines;
|
||||
}
|
||||
@@ -38,12 +38,10 @@ package sonia.scm.repository;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.tmatesoft.svn.core.SVNException;
|
||||
import org.tmatesoft.svn.core.SVNURL;
|
||||
import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
|
||||
import org.tmatesoft.svn.core.io.SVNRepository;
|
||||
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
|
||||
import org.tmatesoft.svn.core.wc.ISVNAnnotateHandler;
|
||||
import org.tmatesoft.svn.core.wc.SVNLogClient;
|
||||
import org.tmatesoft.svn.core.wc.SVNRevision;
|
||||
|
||||
@@ -52,7 +50,6 @@ import org.tmatesoft.svn.core.wc.SVNRevision;
|
||||
import java.io.File;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -100,51 +97,22 @@ public class SvnBlameViewer implements BlameViewer
|
||||
{
|
||||
final List<BlameLine> blameLines = new ArrayList<BlameLine>();
|
||||
File directory = handler.getDirectory(repository);
|
||||
SVNRepository repository = null;
|
||||
SVNRepository svnRepository = null;
|
||||
SVNURL svnurl = null;
|
||||
int total = 0;
|
||||
|
||||
try
|
||||
{
|
||||
svnurl = SVNURL.fromFile(new File(directory, path));
|
||||
repository = SVNRepositoryFactory.create(SVNURL.fromFile(directory));
|
||||
svnRepository = SVNRepositoryFactory.create(SVNURL.fromFile(directory));
|
||||
|
||||
ISVNAuthenticationManager svnManager =
|
||||
repository.getAuthenticationManager();
|
||||
svnRepository.getAuthenticationManager();
|
||||
SVNLogClient svnLogClient = new SVNLogClient(svnManager, null);
|
||||
|
||||
svnLogClient.doAnnotate(svnurl, SVNRevision.HEAD, SVNRevision.HEAD,
|
||||
SVNRevision.HEAD, new ISVNAnnotateHandler()
|
||||
{
|
||||
@Override
|
||||
public void handleLine(Date date, long revision, String author,
|
||||
String line)
|
||||
throws SVNException
|
||||
{
|
||||
|
||||
// Not Used
|
||||
}
|
||||
@Override
|
||||
public void handleLine(Date date, long revision, String author,
|
||||
String line, Date mergedDate,
|
||||
long mergedRevision, String mergedAuthor,
|
||||
String mergedPath, int lineNumber)
|
||||
throws SVNException
|
||||
{
|
||||
blameLines.add(new BlameLine(null, author, date,
|
||||
String.valueOf(revision), line,
|
||||
lineNumber));
|
||||
}
|
||||
@Override
|
||||
public boolean handleRevision(Date date, long revision, String author,
|
||||
File contents)
|
||||
throws SVNException
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void handleEOF() {}
|
||||
});
|
||||
SVNRevision.HEAD,
|
||||
new SvnBlameHandler(blameLines));
|
||||
}
|
||||
catch (Exception ex) {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user