Add branch_is_default info to commits
This commit is contained in:
parent
dbea2f3760
commit
7eb2617e48
|
@ -17,7 +17,7 @@ module Travis
|
||||||
def data
|
def data
|
||||||
{
|
{
|
||||||
'build' => build_data(build),
|
'build' => build_data(build),
|
||||||
'commit' => commit_data(build.commit),
|
'commit' => commit_data(build.commit, build.repository),
|
||||||
'jobs' => options[:include_jobs] ? build.matrix.map { |job| job_data(job) } : [],
|
'jobs' => options[:include_jobs] ? build.matrix.map { |job| job_data(job) } : [],
|
||||||
'annotations' => options[:include_jobs] ? Annotations.new(annotations(build), @options).data["annotations"] : [],
|
'annotations' => options[:include_jobs] ? Annotations.new(annotations(build), @options).data["annotations"] : [],
|
||||||
}
|
}
|
||||||
|
@ -44,11 +44,12 @@ module Travis
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def commit_data(commit)
|
def commit_data(commit, repository)
|
||||||
{
|
{
|
||||||
'id' => commit.id,
|
'id' => commit.id,
|
||||||
'sha' => commit.commit,
|
'sha' => commit.commit,
|
||||||
'branch' => commit.branch,
|
'branch' => commit.branch,
|
||||||
|
'branch_is_default' => branch_is_default(commit, repository),
|
||||||
'message' => commit.message,
|
'message' => commit.message,
|
||||||
'committed_at' => format_date(commit.committed_at),
|
'committed_at' => format_date(commit.committed_at),
|
||||||
'author_name' => commit.author_name,
|
'author_name' => commit.author_name,
|
||||||
|
@ -78,6 +79,10 @@ module Travis
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def branch_is_default(commit, repository)
|
||||||
|
repository.default_branch == commit.branch
|
||||||
|
end
|
||||||
|
|
||||||
def annotations(build)
|
def annotations(build)
|
||||||
build.matrix.map(&:annotations).flatten
|
build.matrix.map(&:annotations).flatten
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,7 @@ module Travis
|
||||||
def data
|
def data
|
||||||
{
|
{
|
||||||
'job' => job_data(job),
|
'job' => job_data(job),
|
||||||
'commit' => commit_data(job.commit),
|
'commit' => commit_data(job.commit, job.repository),
|
||||||
'annotations' => Annotations.new(job.annotations, @options).data["annotations"],
|
'annotations' => Annotations.new(job.annotations, @options).data["annotations"],
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -42,11 +42,12 @@ module Travis
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def commit_data(commit)
|
def commit_data(commit, repository)
|
||||||
{
|
{
|
||||||
'id' => commit.id,
|
'id' => commit.id,
|
||||||
'sha' => commit.commit,
|
'sha' => commit.commit,
|
||||||
'branch' => commit.branch,
|
'branch' => commit.branch,
|
||||||
|
'branch_is_default' => branch_is_default(commit, repository),
|
||||||
'message' => commit.message,
|
'message' => commit.message,
|
||||||
'committed_at' => format_date(commit.committed_at),
|
'committed_at' => format_date(commit.committed_at),
|
||||||
'author_name' => commit.author_name,
|
'author_name' => commit.author_name,
|
||||||
|
@ -56,6 +57,10 @@ module Travis
|
||||||
'compare_url' => commit.compare_url,
|
'compare_url' => commit.compare_url,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def branch_is_default(commit, repository)
|
||||||
|
repository.default_branch == commit.branch
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,6 +29,7 @@ describe Travis::Api::V2::Http::Build do
|
||||||
'id' => 1,
|
'id' => 1,
|
||||||
'sha' => '62aae5f70ceee39123ef',
|
'sha' => '62aae5f70ceee39123ef',
|
||||||
'branch' => 'master',
|
'branch' => 'master',
|
||||||
|
'branch_is_default' => true,
|
||||||
'message' => 'the commit message',
|
'message' => 'the commit message',
|
||||||
'compare_url' => 'https://github.com/svenfuchs/minimal/compare/master...develop',
|
'compare_url' => 'https://github.com/svenfuchs/minimal/compare/master...develop',
|
||||||
'committed_at' => json_format_time(Time.now.utc - 1.hour),
|
'committed_at' => json_format_time(Time.now.utc - 1.hour),
|
||||||
|
|
|
@ -31,6 +31,7 @@ describe Travis::Api::V2::Http::Job do
|
||||||
'sha' => '62aae5f70ceee39123ef',
|
'sha' => '62aae5f70ceee39123ef',
|
||||||
'message' => 'the commit message',
|
'message' => 'the commit message',
|
||||||
'branch' => 'master',
|
'branch' => 'master',
|
||||||
|
'branch_is_default' => true,
|
||||||
'message' => 'the commit message',
|
'message' => 'the commit message',
|
||||||
'committed_at' => json_format_time(Time.now.utc - 1.hour),
|
'committed_at' => json_format_time(Time.now.utc - 1.hour),
|
||||||
'committer_name' => 'Sven Fuchs',
|
'committer_name' => 'Sven Fuchs',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user