Skip to content

Commit ec357df

Browse files
committed
Consistent naming
1 parent 7c553ee commit ec357df

3 files changed

Lines changed: 27 additions & 27 deletions

File tree

cmd/commentprcasdiff/casdiff_runner.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ func runCASDiff(ctx context.Context, transition stateTransition) casDiffResult {
4949

5050
cmd := fmt.Sprintf("```sh\n$ casdiff %s \\\n %s \\\n --format=markdown\n```", transition.fromRef, transition.toRef)
5151
diffOutput := mdiff.String(bufcasdiff.ManifestDiffOutputFormatMarkdown)
52-
if transition.isGlobalTransition {
53-
result.output = "### Global transition\n\n" + cmd + "\n\n" + diffOutput
52+
if transition.isOverallTransition {
53+
result.output = "### Overall transition\n\n" + cmd + "\n\n" + diffOutput
5454
} else {
5555
result.output = fmt.Sprintf(
5656
"**Intermediate transition**\n\n%s\n<details><summary>%s</summary>\n<p>\n\n%s\n</p>\n</details>",

cmd/commentprcasdiff/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func run(ctx context.Context, flags *flags) error {
147147
}
148148
}
149149

150-
overallTransitions, err := getGlobalOverallTransitions(ctx, stateRW, baseRef, headRef)
150+
overallTransitions, err := getOverallTransitions(ctx, stateRW, baseRef, headRef)
151151
if err != nil {
152152
fmt.Fprintf(os.Stderr, "Warning: failed to get overall transitions from global state: %v\n", err)
153153
} else if len(overallTransitions) > 0 {

cmd/commentprcasdiff/state_analyzer.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ import (
3030

3131
// stateTransition represents a digest change in a module's state.json file.
3232
type stateTransition struct {
33-
modulePath string // e.g., "modules/sync/bufbuild/protovalidate"
34-
filePath string // The module where the transition happened, can be an individual module like "modules/sync/bufbuild/protovalidate/state.json" or the global state file "modules/sync/state.json"
35-
fromRef string // Old git reference (e.g., "v1.1.0")
36-
toRef string // New git reference (e.g., "v1.2.0")
37-
fromDigest string // Old digest
38-
toDigest string // New digest
39-
lineNumber int // Line in diff where the new reference or digest appears.
40-
isGlobalTransition bool // True for the transition on the state.json global to all modules.
33+
modulePath string // e.g., "modules/sync/bufbuild/protovalidate"
34+
filePath string // The module where the transition happened, can be an individual module like "modules/sync/bufbuild/protovalidate/state.json" or the global state file "modules/sync/state.json"
35+
fromRef string // Old git reference (e.g., "v1.1.0")
36+
toRef string // New git reference (e.g., "v1.2.0")
37+
fromDigest string // Old digest
38+
toDigest string // New digest
39+
lineNumber int // Line in diff where the new reference or digest appears.
40+
isOverallTransition bool // True for overall transitions on the global state.json file.
4141
}
4242

4343
// getStateFileTransitions reads state.json from base and head branches, compares the JSON arrays to
@@ -100,14 +100,14 @@ func getStateFileTransitions(
100100
lineNumber = lineNumbers[i]
101101
}
102102
transitions = append(transitions, stateTransition{
103-
modulePath: modulePath,
104-
filePath: filePath,
105-
fromRef: currentRef,
106-
toRef: appendedRef.GetName(),
107-
fromDigest: currentDigest,
108-
toDigest: appendedRef.GetDigest(),
109-
lineNumber: lineNumber,
110-
isGlobalTransition: false,
103+
modulePath: modulePath,
104+
filePath: filePath,
105+
fromRef: currentRef,
106+
toRef: appendedRef.GetName(),
107+
fromDigest: currentDigest,
108+
toDigest: appendedRef.GetDigest(),
109+
lineNumber: lineNumber,
110+
isOverallTransition: false,
111111
})
112112
currentDigest = appendedRef.GetDigest()
113113
}
@@ -153,10 +153,10 @@ func resolveAppendedRefs(
153153
return baseRefs[len(baseRefs)-1], headRefs[len(baseRefs):]
154154
}
155155

156-
// getGlobalOverallTransitions reads modules/sync/state.json from both base and head, compares the
156+
// getOverallTransitions reads modules/sync/state.json from both base and head, compares the
157157
// two, and returns one stateTransition per module whose latest_reference changed. Modules that were
158158
// added or removed between base and head are ignored.
159-
func getGlobalOverallTransitions(
159+
func getOverallTransitions(
160160
ctx context.Context,
161161
stateRW *bufstate.ReadWriter,
162162
baseRef string,
@@ -200,12 +200,12 @@ func getGlobalOverallTransitions(
200200
return nil, fmt.Errorf("find line number for %q: %w", moduleName, err)
201201
}
202202
transitions = append(transitions, stateTransition{
203-
modulePath: "modules/sync/" + moduleName,
204-
filePath: globalStatePath,
205-
fromRef: fromRef,
206-
toRef: toRef,
207-
lineNumber: lineNumber,
208-
isGlobalTransition: true,
203+
modulePath: "modules/sync/" + moduleName,
204+
filePath: globalStatePath,
205+
fromRef: fromRef,
206+
toRef: toRef,
207+
lineNumber: lineNumber,
208+
isOverallTransition: true,
209209
})
210210
}
211211
return transitions, nil

0 commit comments

Comments
 (0)