Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
dc982127
Commit
dc982127
authored
Feb 28, 2014
by
Greg Messner
Browse files
Added getBranch() to simplify pulling the branch out of the refs.
parent
a913a19b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/messners/gitlab/api/webhook/PushEvent.java
View file @
dc982127
...
@@ -7,6 +7,8 @@ import javax.xml.bind.annotation.XmlAccessType;
...
@@ -7,6 +7,8 @@ import javax.xml.bind.annotation.XmlAccessType;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
org.codehaus.jackson.annotate.JsonIgnore
;
import
com.messners.gitlab.api.Commit
;
import
com.messners.gitlab.api.Commit
;
import
com.messners.gitlab.api.Repository
;
import
com.messners.gitlab.api.Repository
;
...
@@ -95,4 +97,28 @@ public class PushEvent {
...
@@ -95,4 +97,28 @@ public class PushEvent {
public
void
setUserName
(
String
userName
)
{
public
void
setUserName
(
String
userName
)
{
this
.
userName
=
userName
;
this
.
userName
=
userName
;
}
}
/**
* Gets the branch name from the ref. Will return null if the ref does not start with "refs/heads/".
*
* @return the branch name from the ref
*/
@JsonIgnore
public
String
getBranch
()
{
String
ref
=
getRef
();
if
(
ref
==
null
||
ref
.
trim
().
length
()
==
0
)
{
return
(
null
);
}
ref
=
ref
.
trim
();
int
refsHeadsIndex
=
ref
.
indexOf
(
REFS_HEADS
);
if
(
refsHeadsIndex
!=
0
)
{
return
(
null
);
}
return
(
ref
.
substring
(
REFS_HEADS
.
length
()));
}
private
static
final
String
REFS_HEADS
=
"refs/heads/"
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment