Skip to content

Commit

Permalink
add BuildDisplayName to history item
Browse files Browse the repository at this point in the history
  • Loading branch information
ns3777k committed Aug 23, 2018
1 parent 321ec70 commit 6a8dfdb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 8 additions & 1 deletion build_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func parseBuildHistory(d io.Reader) []*History {
depth := 0
buildRowCellDepth := -1
builds := make([]*History, 0)
isInsideDisplayName := false
var curBuild *History
for {
tt := z.Next()
Expand Down Expand Up @@ -52,11 +53,12 @@ func parseBuildHistory(d io.Reader) []*History {
}
// <a update-parent-class=".build-row" href="/job/appscode/job/43/job/build-binary/227/" class="tip model-link inside build-link display-name">#227</a>
if string(tn) == "a" {
if hasCSSClass(a, "build-link") && buildRowCellDepth > -1 {
if hasCSSClass(a, "display-name") && buildRowCellDepth > -1 {
if href, found := a["href"]; found {
parts := strings.Split(href, "/")
if num, err := strconv.Atoi(parts[len(parts)-2]); err == nil {
curBuild.BuildNumber = num
isInsideDisplayName = true
}
}
}
Expand All @@ -72,6 +74,11 @@ func parseBuildHistory(d io.Reader) []*History {
}
}
}
case html.TextToken:
if isInsideDisplayName {
curBuild.BuildDisplayName = z.Token().Data
isInsideDisplayName = false
}
case html.EndTagToken:
tn, _ := z.TagName()
if string(tn) == "td" && depth == buildRowCellDepth {
Expand Down
7 changes: 4 additions & 3 deletions job.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ func (j *Job) parentBase() string {
}

type History struct {
BuildNumber int
BuildStatus string
BuildTimestamp int64
BuildDisplayName string
BuildNumber int
BuildStatus string
BuildTimestamp int64
}

func (j *Job) GetName() string {
Expand Down

0 comments on commit 6a8dfdb

Please sign in to comment.