MCPcopy Create free account
hub / github.com/LegacyCodeHQ/clarity-cli / buildGraphLabel

Function buildGraphLabel

cmd/show/show_cmd.go:1320–1363  ·  view source on GitHub ↗
(opts *graphOptions, format formatters.OutputFormat, fromCommit, toCommit string, isCommitRange bool, filePaths []string, moduleCount, deletedCount int)

Source from the content-addressed store, hash-verified

1318}
1319
1320func buildGraphLabel(opts *graphOptions, format formatters.OutputFormat, fromCommit, toCommit string, isCommitRange bool, filePaths []string, moduleCount, deletedCount int) string {
1321 if format != formatters.OutputFormatDOT && format != formatters.OutputFormatMermaid {
1322 return ""
1323 }
1324
1325 labelRepoPath := opts.repoPath
1326 if labelRepoPath == "" {
1327 labelRepoPath = "."
1328 }
1329
1330 label := fmt.Sprintf("%s • ", repoLabelName(labelRepoPath))
1331 var err error
1332
1333 var commitLabel string
1334 if opts.commitID != "" {
1335 if isCommitRange {
1336 commitLabel, err = git.GetCommitRangeLabel(labelRepoPath, fromCommit, toCommit)
1337 } else {
1338 commitLabel, err = git.GetShortCommitHash(labelRepoPath, toCommit)
1339 }
1340 } else {
1341 commitLabel, err = git.GetCurrentCommitHash(labelRepoPath)
1342 }
1343
1344 if err != nil {
1345 return ""
1346 }
1347
1348 label += commitLabel
1349 if opts.commitID == "" {
1350 isDirty, err := git.HasUncommittedChanges(labelRepoPath)
1351 if err == nil && isDirty {
1352 label += "-dirty"
1353 }
1354 }
1355
1356 presentFiles := len(filePaths) - moduleCount - deletedCount
1357 if presentFiles < 0 {
1358 presentFiles = 0
1359 }
1360 label += " • " + graphCountLabel(moduleCount, presentFiles, deletedCount)
1361
1362 return label
1363}
1364
1365// graphCountLabel summarizes the graph's node counts for the title: the node
1366// composition (modules and present files) and a separate deleted-file count.

Callers 2

runGraphFunction · 0.85

Calls 6

GetCommitRangeLabelFunction · 0.92
GetShortCommitHashFunction · 0.92
GetCurrentCommitHashFunction · 0.92
HasUncommittedChangesFunction · 0.92
repoLabelNameFunction · 0.85
graphCountLabelFunction · 0.85