Method: Changelog::Log#getReleasesFromServices

Defined in:
lib/changelog.rb

#getReleasesFromServicesObject

TRAVIS_COMMIT_RANGE



337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
# File 'lib/changelog.rb', line 337

def getReleasesFromServices


  #user = @github.client.user
  #user.login


  result = []

  all_releases = @github.releases
  #p all_releases.inspect
  r = all_releases.first
  #p r
  p r.tag_name
  ref = @github.ref(r.tag_name)
  sha = ref.object.sha
  commit = @github.commit(sha).commit
  since = commit.author.date

  commits = @github.commits_since(since)
  commits.pop #remove commit from last release - not sure why this in necessary and recon that it is not accurate either

  items = []
  commits.each { |c| items.concat(itemsFromCommit(c)) }

  release = Release.new("Next Version", "NA", sha, since, "NA", items)

  result << release

  releases = all_releases.take(ENV['NO_OF_RELEASES'].to_i)

  releases.each_with_index { |r, index|

    next_r = all_releases[index+1] unless index == all_releases.size - 1 #note we use all_releases for this
    ref = @github.ref(r.tag_name)
    sha = ref.object.sha
    commit = @github.commit(sha).commit

    to = commit.author.date

    if next_r
      next_ref = @github.ref(next_r.tag_name)
      next_sha = next_ref.object.sha
      next_commit = @github.commit(next_sha).commit
      from = next_commit.author.date
      commits = @github.client.commits_between(ENV['TRAVIS_REPO_SLUG'], from, to, ENV['TRAVIS_BRANCH'])
    else
      commits = @github.client.commits_before(ENV['TRAVIS_REPO_SLUG'], to, ENV['TRAVIS_BRANCH'])
    end

    items = []
    commits.each { |c| items.concat(itemsFromCommit(c)) }

    release = Release.new(r.tag_name, r.name, sha, to, githubReleaseStatus(r), items)

    result << release
  }
  return result
end