Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Historical data param, git tagName #36

Merged
merged 7 commits into from
Dec 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use tag or branch name.
  • Loading branch information
handstandsam committed Dec 2, 2024
commit 2476bcdda87238622719fd967251b860695c5fa4
Original file line number Diff line number Diff line change
@@ -54,6 +54,19 @@ internal class GitDataCollector(private val gitProjectRootDir: File) {
return exec("git rev-parse --abbrev-ref HEAD", gitProjectRootDir).stdOut.lines()[0]
}

fun currentTag(): GitBranch? {
val cmdResult = exec("git describe --tags --exact-match", gitProjectRootDir).stdOut.lines()[0]
return if (cmdResult.contains("fatal: no tag exactly matches")) {
null
} else {
cmdResult
}
}

fun currentBranchOrTag(): GitBranch {
return currentTag() ?: currentBranch()
}

/**
*
* Example output of the command is:
Original file line number Diff line number Diff line change
@@ -44,10 +44,10 @@ class InvertReportWriter(

val globalStats = computeGlobalTotals(allProjectsStatsData, collectedOwnershipInfo)

val historicalDataWithCurrent = historicalData + HistoricalData(
val historicalDataWithCurrent = (historicalData + HistoricalData(
reportMetadata = reportMetadata,
statTotalsAndMetadata = CollectedStatTotalsJsReportModel(globalStats)
)
)).sortedBy { it.reportMetadata.latestCommitTime }

// JSON Report
InvertJsonReportWriter(invertLogger, rootBuildReportsDir).createInvertJsonReport(
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ object ProjectMetadataCollector {
.withZone(TimeZone.getTimeZone(timeZoneId).toZoneId())

val gitDataCollector = GitDataCollector(gitProjectDir)
val currentBranch: GitBranch = gitDataCollector.currentBranch()
val currentBranch: GitBranch = gitDataCollector.currentBranchOrTag()
val currentBranchHash = gitDataCollector.gitShaOfBranch(currentBranch, logger)

val latestCommitTimestamp = gitDataCollector.latestCommitTimestamp()