mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-02 19:45:51 +01:00
added author to changesets
This commit is contained in:
@@ -206,14 +206,9 @@ public class GitChangesetViewer implements ChangesetViewer
|
||||
|
||||
date = date * 1000;
|
||||
|
||||
String author = null;
|
||||
PersonIdent person = commit.getCommitterIdent();
|
||||
|
||||
if (person != null)
|
||||
{
|
||||
author = person.getName();
|
||||
}
|
||||
|
||||
PersonIdent authorIndent = commit.getCommitterIdent();
|
||||
Person author = new Person(authorIndent.getName(),
|
||||
authorIndent.getEmailAddress());
|
||||
String message = commit.getShortMessage();
|
||||
Changeset changeset = new Changeset(id, date, author, message);
|
||||
Modifications modifications = createModifications(treeWalk, commit);
|
||||
|
||||
@@ -147,7 +147,7 @@ public class HgChangesetParser
|
||||
}
|
||||
else if ("author".equals(name))
|
||||
{
|
||||
changeset.setAuthor(value);
|
||||
changeset.setAuthor(Person.toPerson(value));
|
||||
}
|
||||
else if ("description".equals(name))
|
||||
{
|
||||
|
||||
@@ -179,7 +179,8 @@ public class SvnChangesetViewer implements ChangesetViewer
|
||||
private Changeset createChangeset(SVNLogEntry entry)
|
||||
{
|
||||
Changeset changeset = new Changeset(String.valueOf(entry.getRevision()),
|
||||
entry.getDate().getTime(), entry.getAuthor(),
|
||||
entry.getDate().getTime(),
|
||||
Person.toPerson(entry.getAuthor()),
|
||||
entry.getMessage());
|
||||
Map<String, SVNLogEntryPath> changeMap = entry.getChangedPaths();
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ package sonia.scm.repository;
|
||||
|
||||
import sonia.scm.Validateable;
|
||||
import sonia.scm.util.Util;
|
||||
import sonia.scm.util.ValidationUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
@@ -79,7 +80,7 @@ public class Changeset implements Validateable, Cloneable, Serializable
|
||||
* @param date
|
||||
* @param author
|
||||
*/
|
||||
public Changeset(String id, Long date, String author)
|
||||
public Changeset(String id, Long date, Person author)
|
||||
{
|
||||
this(id, date, author, null);
|
||||
}
|
||||
@@ -93,7 +94,7 @@ public class Changeset implements Validateable, Cloneable, Serializable
|
||||
* @param author
|
||||
* @param description
|
||||
*/
|
||||
public Changeset(String id, Long date, String author, String description)
|
||||
public Changeset(String id, Long date, Person author, String description)
|
||||
{
|
||||
this.id = id;
|
||||
this.date = date;
|
||||
@@ -250,7 +251,7 @@ public class Changeset implements Validateable, Cloneable, Serializable
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getAuthor()
|
||||
public Person getAuthor()
|
||||
{
|
||||
return author;
|
||||
}
|
||||
@@ -345,7 +346,8 @@ public class Changeset implements Validateable, Cloneable, Serializable
|
||||
@Override
|
||||
public boolean isValid()
|
||||
{
|
||||
return Util.isNotEmpty(id) && Util.isNotEmpty(author) && (date != null);
|
||||
return Util.isNotEmpty(id) && ValidationUtil.isValid(author)
|
||||
&& (date != null);
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
@@ -356,7 +358,7 @@ public class Changeset implements Validateable, Cloneable, Serializable
|
||||
*
|
||||
* @param author
|
||||
*/
|
||||
public void setAuthor(String author)
|
||||
public void setAuthor(Person author)
|
||||
{
|
||||
this.author = author;
|
||||
}
|
||||
@@ -430,7 +432,7 @@ public class Changeset implements Validateable, Cloneable, Serializable
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** The author of the changeset */
|
||||
private String author;
|
||||
private Person author;
|
||||
|
||||
/** The tags associated with the changeset */
|
||||
private List<String> branches;
|
||||
|
||||
210
scm-core/src/main/java/sonia/scm/repository/Person.java
Normal file
210
scm-core/src/main/java/sonia/scm/repository/Person.java
Normal file
@@ -0,0 +1,210 @@
|
||||
/**
|
||||
* 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 sonia.scm.Validateable;
|
||||
import sonia.scm.util.Util;
|
||||
import sonia.scm.util.ValidationUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* the person (author) of a changeset
|
||||
*
|
||||
* @person Sebastian Sdorra
|
||||
*/
|
||||
@XmlRootElement(name = "person")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class Person implements Validateable
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
public Person() {}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public Person(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
* @param mail
|
||||
*/
|
||||
public Person(String name, String mail)
|
||||
{
|
||||
this.name = name;
|
||||
this.mail = mail;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param value
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Person toPerson(String value)
|
||||
{
|
||||
Person person = null;
|
||||
|
||||
if (Util.isNotEmpty(value))
|
||||
{
|
||||
String name = value;
|
||||
String mail = null;
|
||||
int s = value.indexOf("<");
|
||||
int e = value.indexOf(">");
|
||||
|
||||
if ((s > 0) && (e > 0))
|
||||
{
|
||||
name = value.substring(0, s).trim();
|
||||
mail = value.substring(s+1, e).trim();
|
||||
}
|
||||
|
||||
person = new Person(name, mail);
|
||||
}
|
||||
|
||||
return person;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
String out = name;
|
||||
|
||||
if (mail != null)
|
||||
{
|
||||
out = out.concat(" <").concat(mail).concat(">");
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* returns the mail address of the changeset person
|
||||
*
|
||||
*
|
||||
* @returnmail address of the changeset person
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getMail()
|
||||
{
|
||||
return mail;
|
||||
}
|
||||
|
||||
/**
|
||||
* return the name of the changeset person
|
||||
*
|
||||
*
|
||||
* @return name of the changeset person
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns true if the person is valid
|
||||
*
|
||||
*
|
||||
* @return true if the person is valid
|
||||
*/
|
||||
@Override
|
||||
public boolean isValid()
|
||||
{
|
||||
return Util.isNotEmpty(name)
|
||||
&& (Util.isEmpty(mail) || ValidationUtil.isMailAddressValid(mail));
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* sets the mail address of the changeset person
|
||||
*
|
||||
*
|
||||
* @param mail
|
||||
*/
|
||||
public void setMail(String mail)
|
||||
{
|
||||
this.mail = mail;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the name of the changeset person
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** name of the person */
|
||||
private String mail;
|
||||
|
||||
/** mail address of the person */
|
||||
private String name;
|
||||
}
|
||||
@@ -33,6 +33,10 @@
|
||||
|
||||
package sonia.scm.util;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.Validateable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -107,4 +111,17 @@ public class ValidationUtil
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param validateable
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static boolean isValid(Validateable validateable)
|
||||
{
|
||||
return (validateable != null) && validateable.isValid();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -814,9 +814,10 @@ Ext.reg('repositoryPanel', Sonia.repository.Panel);
|
||||
Sonia.repository.ChangesetViewerGrid = Ext.extend(Ext.grid.GridPanel, {
|
||||
|
||||
repository: null,
|
||||
changesetMetadataTemplate: '<div class="changeset-description">{description:htmlEncode}</div>\
|
||||
<div class="changeset-author">{author:htmlEncode}</div>\
|
||||
<div class="changeset-date">{date:formatTimestamp}</div>',
|
||||
mailTemplate: '<<a href="mailto: {0}">{0}</a>>',
|
||||
changesetMetadataTemplate: '<div class="changeset-description">{0}</div>\
|
||||
<div class="changeset-author">{1}</div>\
|
||||
<div class="changeset-date">{2}</div>',
|
||||
modificationsTemplate: 'A: {0}, M: {1}, D: {2}',
|
||||
idsTemplate: 'Commit: {0}',
|
||||
tagsAndBranchesTemplate: '<div class="changeset-tags">{0}</div>\
|
||||
@@ -831,9 +832,9 @@ Sonia.repository.ChangesetViewerGrid = Ext.extend(Ext.grid.GridPanel, {
|
||||
},
|
||||
columns: [{
|
||||
id: 'metadata',
|
||||
xtype: 'templatecolumn',
|
||||
dataIndex: 'author',
|
||||
tpl: this.changesetMetadataTemplate
|
||||
renderer: this.renderChangesetMetadata,
|
||||
scope: this
|
||||
},{
|
||||
id: 'tagsAndBranches',
|
||||
renderer: this.renderTagsAndBranches,
|
||||
@@ -867,6 +868,30 @@ Sonia.repository.ChangesetViewerGrid = Ext.extend(Ext.grid.GridPanel, {
|
||||
Sonia.repository.ChangesetViewerGrid.superclass.initComponent.apply(this, arguments);
|
||||
},
|
||||
|
||||
renderChangesetMetadata: function(author, p, record){
|
||||
var authorValue = '';
|
||||
if ( author != null ){
|
||||
authorValue = Ext.util.Format.htmlEncode(author.name);
|
||||
if ( author.mail != null ){
|
||||
authorValue += ' ' + String.format(this.mailTemplate, author.mail);
|
||||
}
|
||||
}
|
||||
var description = record.data.description;
|
||||
if ( description != null ){
|
||||
description = Ext.util.Format.htmlEncode(description);
|
||||
}
|
||||
var date = record.data.date;
|
||||
if ( date != null ){
|
||||
date = Ext.util.Format.formatTimestamp(date);
|
||||
}
|
||||
return String.format(
|
||||
this.changesetMetadataTemplate,
|
||||
description,
|
||||
authorValue,
|
||||
date
|
||||
);
|
||||
},
|
||||
|
||||
renderTagsAndBranches: function(value, p, record){
|
||||
var tags = this.getLabeledValue("Tags", record.data.tags);
|
||||
var branches = this.getLabeledValue("Branches", record.data.branches);
|
||||
|
||||
Reference in New Issue
Block a user