mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-03 03:55:51 +01:00
expose latest changeset id of branch
This commit is contained in:
@@ -73,12 +73,28 @@ public final class Branch implements Serializable
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param name name of the branch
|
* @param name name of the branch
|
||||||
|
*
|
||||||
|
* @deprecated use {@link Branch#Branch(String, String)} instead
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public Branch(String name)
|
public Branch(String name)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new branch.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param name name of the branch
|
||||||
|
* @param revision latest revision of the branch
|
||||||
|
*/
|
||||||
|
public Branch(String name, String revision)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
this.revision = revision;
|
||||||
|
}
|
||||||
|
|
||||||
//~--- methods --------------------------------------------------------------
|
//~--- methods --------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,7 +120,8 @@ public final class Branch implements Serializable
|
|||||||
|
|
||||||
final Branch other = (Branch) obj;
|
final Branch other = (Branch) obj;
|
||||||
|
|
||||||
return Objects.equal(name, other.name);
|
return Objects.equal(name, other.name)
|
||||||
|
&& Objects.equal(revision, other.revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -116,7 +133,7 @@ public final class Branch implements Serializable
|
|||||||
@Override
|
@Override
|
||||||
public int hashCode()
|
public int hashCode()
|
||||||
{
|
{
|
||||||
return Objects.hashCode(name);
|
return Objects.hashCode(name, revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -131,6 +148,7 @@ public final class Branch implements Serializable
|
|||||||
//J-
|
//J-
|
||||||
return Objects.toStringHelper(this)
|
return Objects.toStringHelper(this)
|
||||||
.add("name", name)
|
.add("name", name)
|
||||||
|
.add("revision", revision)
|
||||||
.toString();
|
.toString();
|
||||||
//J+
|
//J+
|
||||||
}
|
}
|
||||||
@@ -148,8 +166,21 @@ public final class Branch implements Serializable
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the latest revision of the branch.
|
||||||
|
*
|
||||||
|
* @return latest revision of branch
|
||||||
|
*/
|
||||||
|
public String getRevision()
|
||||||
|
{
|
||||||
|
return revision;
|
||||||
|
}
|
||||||
|
|
||||||
//~--- fields ---------------------------------------------------------------
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|
||||||
/** name of the branch */
|
/** name of the branch */
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private String revision;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ public class GitBranchesCommand extends AbstractGitCommand
|
|||||||
|
|
||||||
if (branchName != null)
|
if (branchName != null)
|
||||||
{
|
{
|
||||||
branch = new Branch(branchName);
|
branch = new Branch(branchName, GitUtil.getId(ref.getObjectId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return branch;
|
return branch;
|
||||||
|
|||||||
@@ -30,10 +30,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.repository.spi;
|
package sonia.scm.repository.spi;
|
||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
|
import com.aragost.javahg.Changeset;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
@@ -92,7 +95,15 @@ public class HgBranchesCommand extends AbstractCommand
|
|||||||
@Override
|
@Override
|
||||||
public Branch apply(com.aragost.javahg.commands.Branch hgBranch)
|
public Branch apply(com.aragost.javahg.commands.Branch hgBranch)
|
||||||
{
|
{
|
||||||
return new Branch(hgBranch.getName());
|
String node = null;
|
||||||
|
Changeset changeset = hgBranch.getBranchTip();
|
||||||
|
|
||||||
|
if (changeset != null)
|
||||||
|
{
|
||||||
|
node = changeset.getNode();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Branch(hgBranch.getName(), node);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user