Skip to content

Commit

Permalink
Fix release notes issue when previous commit was a merge commit (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
mirland authored May 4, 2019
1 parent 9642baa commit 21a9096
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ Change Log
==========
All notable changes to this project will be documented in this file.

[Version 1.0.3 _(UNRELEASED)_](https://github.com/xmartlabs/android-snapshot-publisher/releases/tag/v1.0.3)
---

### Fixes
- Fix release notes issue when previous commit was a merge commit(#31)

[Version 1.0.2 _(2018-04-30)_](https://github.com/xmartlabs/android-snapshot-publisher/releases/tag/v1.0.2)
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ internal object GitHelper {
return proc.inputStream.bufferedReader().readText().trim()
}

private fun getPreviousTag() = "git describe --tags --abbrev=0 HEAD^".execute()
private fun getPreviousTag() = "git describe --tags --abbrev=0 ${getPreviousCommitHash()}".execute()

private fun getPreviousCommitHash() = "git log --format=%H --skip 1 -1".execute()

fun getCommitHash() = "git rev-parse --short HEAD".execute()

Expand All @@ -39,7 +41,7 @@ internal object GitHelper {

private fun getHistoryRange(releaseNotesConfig: ReleaseNotesConfig): String {
val startRange = if (releaseNotesConfig.includeHistorySinceLastTag) getPreviousTag() else null
val endRange = "HEAD" + if (releaseNotesConfig.includeLastCommitInHistory) "" else "^"
val endRange = if (releaseNotesConfig.includeLastCommitInHistory) "HEAD" else getPreviousCommitHash()
return if (startRange.isNullOrBlank()) endRange else "$startRange..$endRange"
}

Expand Down

0 comments on commit 21a9096

Please sign in to comment.