From cd8ed15054c08c56a5b5a57d2000b85aeba2e3e6 Mon Sep 17 00:00:00 2001 From: Richard Gomez Date: Wed, 12 Jul 2023 18:29:23 -0400 Subject: [PATCH] Update logic and tests --- pkg/gitparse/gitparse.go | 9 +- pkg/gitparse/gitparse_test.go | 628 +++++++++++++++++++++++++--------- 2 files changed, 473 insertions(+), 164 deletions(-) diff --git a/pkg/gitparse/gitparse.go b/pkg/gitparse/gitparse.go index 19ca77682872..c00457a92d67 100644 --- a/pkg/gitparse/gitparse.go +++ b/pkg/gitparse/gitparse.go @@ -422,11 +422,12 @@ func isCommitLine(isStaged bool, latestState ParseState, line []byte) bool { latestState == ModeLine || latestState == IndexLine || latestState == BinaryFileLine || + latestState == ToFileLine || latestState == HunkContentLine) { return false } - if len(line) > 7 && bytes.Equal(line[:6], []byte("commit")) { + if len(line) > 7 && bytes.Equal(line[:7], []byte("commit ")) { return true } return false @@ -513,7 +514,7 @@ func isDiffLine(isStaged bool, latestState ParseState, line []byte) bool { // rename to new.txt // deleted file mode 100644 func isModeLine(isStaged bool, latestState ParseState, line []byte) bool { - if isStaged || !(latestState == DiffLine || latestState == ModeLine) { + if !(latestState == DiffLine || latestState == ModeLine) { return false } // This could probably be better written. @@ -658,7 +659,7 @@ func isHunkEmptyLine(isStaged bool, latestState ParseState, line []byte) bool { } func isCommitSeparatorLine(isStaged bool, latestState ParseState, line []byte) bool { - if (latestState == ModeLine || latestState == IndexLine || latestState == BinaryFileLine) && + if (latestState == ModeLine || latestState == IndexLine || latestState == BinaryFileLine || latestState == ToFileLine) && len(line) == 1 && bytes.Equal(line[:1], []byte("\n")) { return true } @@ -667,7 +668,7 @@ func isCommitSeparatorLine(isStaged bool, latestState ParseState, line []byte) b func cleanupParse(currentCommit *Commit, currentDiff *Diff, commitChan chan Commit, totalLogSize *int) { // Ignore empty or binary diffs (this condition may be redundant). - if currentDiff != nil && (currentDiff.Content.Len() > 0 || !currentDiff.IsBinary) { + if currentDiff != nil && currentDiff.Content.Len() > 0 { currentCommit.Diffs = append(currentCommit.Diffs, *currentDiff) } if currentCommit != nil { diff --git a/pkg/gitparse/gitparse_test.go b/pkg/gitparse/gitparse_test.go index 29ec39e64740..c4cd2748bbd9 100644 --- a/pkg/gitparse/gitparse_test.go +++ b/pkg/gitparse/gitparse_test.go @@ -548,164 +548,101 @@ func newStringBuilderValue(value string) strings.Builder { } func TestCommitParsing(t *testing.T) { + r := bytes.NewReader([]byte(commitLog)) + commitChan := make(chan Commit) + parser := NewParser() + go func() { + parser.FromReader(context.Background(), r, commitChan, false) + }() + i := 0 + for commit := range commitChan { + if len(expectedCommits) <= i { + t.Errorf("Missing expected case for commit: %+v", commit) + break + } + + if !commit.Equal(&expectedCommits[i]) { + t.Errorf("Commit does not match.\nexpected: %+v\n%s\nactual : %+v\n%s", expectedCommits[i], expectedCommits[i].Message.String(), commit, commit.Message.String()) + } + i++ + } +} + +func TestIndividualCommitParsing(t *testing.T) { + // Arrange + commits := strings.Split(commitLog, "\ncommit ") + for index, commit := range commits { + if !strings.HasPrefix(commit, "commit") { + commits[index] = "commit " + commit + } + } + + // Act + for i, commit := range commits { + r := bytes.NewReader([]byte(commit)) + commitChan := make(chan Commit) + parser := NewParser() + go func() { + parser.FromReader(context.Background(), r, commitChan, false) + }() + j := 0 + for commit := range commitChan { + if len(expectedCommits) <= i { + t.Errorf("Missing expected case for commit: %+v", commit) + break + } + + // Assert + if !commit.Equal(&expectedCommits[i]) { + t.Errorf("Commit does not match.\nexpected: %+v\n%s\nactual : %+v\n%s", expectedCommits[i], expectedCommits[j].Message.String(), commit, commit.Message.String()) + } + j++ + } + //for _, pass := range test.passes { + // if !test.function(false, pass.latestState, pass.line) { + // t.Errorf("%s: Parser did not recognize correct line. (%s)", name, string(pass.line)) + // } + //} + //for _, fail := range test.fails { + // if test.function(false, fail.latestState, fail.line) { + // t.Errorf("%s: Parser did not recognize incorrect line. (%s)", name, string(fail.line)) + // } + //} + } +} + +func TestStagedDiffs(t *testing.T) { expected := []Commit{ - // Empty commit and message. Lord help us. - { - Hash: "4727ffb7ad6dc5130bf4b4dd166e00705abdd018", - Author: "John Smith ", - Date: newTime("Tue Jul 11 22:26:11 2023 -0400"), - Message: strings.Builder{}, - Diffs: []Diff{}, - }, { - Hash: "c904e0f5cd9f30ae520c66bd5f70806219fe7ca2", - Author: "John Smith ", - Date: newTime("Mon Jul 10 10:17:11 2023 -0400"), - Message: newStringBuilderValue("Empty Commit\n"), - Diffs: []Diff{}, - }, - { - Hash: "3d76a97faad96e0f326afb61c232b9c2a18dca35", - Author: "John Smith ", - Date: newTime("Tue Jul 11 18:03:54 2023 -0400"), + Hash: "", + Author: "", + Date: newTime("0001-01-01 00:00:00 +0000 UTC"), Message: strings.Builder{}, Diffs: []Diff{ { - PathB: "sample.txt", + PathB: "aws", LineStart: 1, - Content: *bytes.NewBuffer([]byte("Hello, world!\n")), + Content: *bytes.NewBuffer([]byte("[default]\naws_access_key_id = AKIAXYZDQCEN4B6JSJQI\naws_secret_access_key = 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\noutput = json\nregion = us-east-2\n")), IsBinary: false, }, - }, - }, - { - Hash: "934cf5d255fd8e28b33f5a6ba64276caf0b284bf", - Author: "John Smith ", - Date: newTime("Tue Jul 11 18:43:22 2023 -0400"), - Message: newStringBuilderValue("Test toFile/plusLine parsing\n"), - Diffs: []Diff{ { - PathB: "plusLine.txt", + PathB: "aws2", LineStart: 1, - Content: *bytes.NewBuffer([]byte("-- test\n++ test\n\n")), + Content: *bytes.NewBuffer([]byte("\n\nthis is the secret: [Default]\nAccess key Id: AKIAILE3JG6KMS3HZGCA\nSecret Access Key: 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\n\nokay thank you bye\n")), IsBinary: false, }, - }, - }, - { - Hash: "2a5d703b02b52d65c65ee9f7928f158b919ab741", - Author: "Sergey Beryozkin ", - Date: newTime("Fri Jul 7 17:44:26 2023 +0100"), - Message: newStringBuilderValue("Do not refresh OIDC session if the user is requesting logout\n"), - Diffs: []Diff{ - { - PathB: "extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/BackChannelLogoutTokenCache.java", - LineStart: 45, - Content: *bytes.NewBuffer([]byte("\n\n public boolean containsTokenVerification(String token) {\n return cacheMap.containsKey(token);\n }\n\n\n\n\n")), - IsBinary: false, - }, - { - PathB: "extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/CodeAuthenticationMechanism.java", - LineStart: 1023, - Content: *bytes.NewBuffer([]byte("\n\n private boolean isRpInitiatedLogout(RoutingContext context, TenantConfigContext configContext) {\n\n\n")), - IsBinary: false, - }, - { - PathB: "extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/CodeAuthenticationMechanism.java", - LineStart: 1214, - Content: *bytes.NewBuffer([]byte("\n\n\n\n private class LogoutCall implements Function> {\n RoutingContext context;\n TenantConfigContext configContext;\n String idToken;\n\n LogoutCall(RoutingContext context, TenantConfigContext configContext, String idToken) {\n this.context = context;\n this.configContext = configContext;\n this.idToken = idToken;\n }\n\n @Override\n public Uni apply(SecurityIdentity identity) {\n if (isRpInitiatedLogout(context, configContext)) {\n LOG.debug(\"Performing an RP initiated logout\");\n fireEvent(SecurityEvent.Type.OIDC_LOGOUT_RP_INITIATED, identity);\n return buildLogoutRedirectUriUni(context, configContext, idToken);\n }\n if (isBackChannelLogoutPendingAndValid(configContext, identity)\n || isFrontChannelLogoutValid(context, configContext,\n identity)) {\n return removeSessionCookie(context, configContext.oidcConfig)\n .map(new Function() {\n @Override\n public Void apply(Void t) {\n throw new LogoutException();\n }\n });\n\n }\n return VOID_UNI;\n }\n }\n\n")), - IsBinary: false, - }, - { - PathB: "integration-tests/oidc-wiremock/src/main/resources/application.properties", - LineStart: 20, - Content: *bytes.NewBuffer([]byte("\n\n\nquarkus.oidc.code-flow.token.refresh-expired=true\nquarkus.oidc.code-flow.token.refresh-token-time-skew=5M\n\n\n")), - IsBinary: false, - }, - // WTF, shouldn't this be filtered out? - { - PathB: "integration-tests/oidc-wiremock/src/test/java/io/quarkus/it/keycloak/CodeFlowAuthorizationTest.java", - LineStart: 6, - Content: *bytes.NewBuffer([]byte("\n\n\n\n\n\n")), - IsBinary: false, - }, - { - PathB: "integration-tests/oidc-wiremock/src/test/java/io/quarkus/it/keycloak/CodeFlowAuthorizationTest.java", - LineStart: 76, - Content: *bytes.NewBuffer([]byte("\n\n // Logout\n\n\n\n")), - IsBinary: false, - }, - }, - }, - { - Hash: "2a057632d7f5fa3d1c77b9aa037263211c0e0290", - Author: "rjtmahinay ", - Date: newTime("Mon Jul 10 01:22:32 2023 +0800"), - Message: newStringBuilderValue("Add QuarkusApplication javadoc\n\n* Fix #34463\n"), - Diffs: []Diff{ { PathB: "core/runtime/src/main/java/io/quarkus/runtime/QuarkusApplication.java", LineStart: 3, Content: *bytes.NewBuffer([]byte("/**\n * This is usually used for command mode applications with a startup logic. The logic is executed inside\n * {@link QuarkusApplication#run} method before the main application exits.\n */\n")), IsBinary: false, }, - }, - }, - { - Hash: "bca2d17491015ea1522f34517223b5a366aea73c", - Author: "John Smith ", - Date: newTime("Tue Jul 11 18:12:21 2023 -0400"), - Message: newStringBuilderValue("Delete binary file\n"), - Diffs: []Diff{}, - }, - { - Hash: "afc6dc5d47f28366638da877ecb6b819c69e659b", - Author: "John Smith ", - Date: newTime("Mon Jul 10 12:21:33 2023 -0400"), - Message: newStringBuilderValue("Change binary file\n"), - Diffs: []Diff{}, - }, - { - Hash: "638595917417c5c8a956937b28c5127719023363", - Author: "John Smith ", - Date: newTime("Mon Jul 10 12:20:35 2023 -0400"), - Message: newStringBuilderValue("Add binary file\n"), - Diffs: []Diff{}, - }, - { - Hash: "ce0f5d1fe0272f180ccb660196f439c0c2f4ec8e", - Author: "John Smith ", - Date: newTime("Tue Jul 11 18:08:52 2023 -0400"), - Message: newStringBuilderValue("Delete file\n"), - Diffs: []Diff{}, - }, - { - Hash: "d606a729383371558473b70a6a7b1ca264b0d205", - Author: "John Smith ", - Date: newTime("Mon Jul 10 14:17:04 2023 -0400"), - Message: newStringBuilderValue("Rename file\n"), - Diffs: []Diff{}, - }, - { - Hash: "7bd16429f1f708746dabf970e54b05d2b4734997", - Author: "John Smith ", - Date: newTime("Tue Jul 11 18:10:49 2023 -0400"), - Message: newStringBuilderValue("Change file\n"), - Diffs: []Diff{ { PathB: "tzu", LineStart: 11, Content: *bytes.NewBuffer([]byte("\n\n\n\nSource: https://www.gnu.org/software/diffutils/manual/diffutils.html#An-Example-of-Unified-Format\n")), IsBinary: false, }, - }, - }, - { - Hash: "c7062674c17192caa284615ab2fa9778c6602164", - Author: "John Smith ", - Date: newTime("Mon Jul 10 10:15:18 2023 -0400"), - Message: newStringBuilderValue("Create files\n"), - Diffs: []Diff{ { PathB: "lao", LineStart: 1, @@ -718,33 +655,28 @@ func TestCommitParsing(t *testing.T) { Content: *bytes.NewBuffer([]byte("The Nameless is the origin of Heaven and Earth;\nThe named is the mother of all things.\n\nTherefore let there always be non-being,\n so we may see their subtlety,\nAnd let there always be being,\n so we may see their outcome.\nThe two are the same,\nBut after they are produced,\n they have different names.\nThey both may be called deep and profound.\nDeeper and more profound,\nThe door of all subtleties!\n")), IsBinary: false, }, + //{ + // PathB: "", + // LineStart: 0, + // Content: *bytes.NewBuffer([]byte("\n")), + // IsBinary: false, + //}, + //{ + // PathB: "", + // LineStart: 0, + // Content: *bytes.NewBuffer([]byte("\n")), + // IsBinary: false, + //}, + //{ + // PathB: "", + // LineStart: 0, + // Content: *bytes.NewBuffer([]byte("\n")), + // IsBinary: false, + //}, }, }, } - r := bytes.NewReader([]byte(multipleCommits)) - commitChan := make(chan Commit) - parser := NewParser() - go func() { - parser.FromReader(context.Background(), r, commitChan, false) - }() - i := 0 - for commit := range commitChan { - if len(expected) <= i { - t.Errorf("Missing expected case for commit: %+v", commit) - break - } - - if !commit.Equal(&expected[i]) { - t.Errorf("Commit does not match.\nexpected: %+v\n%s\nactual : %+v\n%s", expected[i], expected[i].Message.String(), commit, commit.Message.String()) - } - i++ - } -} - -func TestStagedDiffs(t *testing.T) { - expected := []Commit{} - r := bytes.NewReader([]byte(stagedDiffs)) commitChan := make(chan Commit) parser := NewParser() @@ -910,7 +842,7 @@ Co-authored-by: Sergey Beryozkin } } -const multipleCommits = `commit 4727ffb7ad6dc5130bf4b4dd166e00705abdd018 (HEAD -> master) +const commitLog = `commit 4727ffb7ad6dc5130bf4b4dd166e00705abdd018 (HEAD -> master) Author: John Smith Date: Tue Jul 11 22:26:11 2023 -0400 @@ -1298,8 +1230,384 @@ index 0000000..5af88a8 +The door of all subtleties! ` -// TODO -const stagedDiffs = `` +var expectedCommits = []Commit{ + // Empty commit and message. Lord help us. + { + Hash: "4727ffb7ad6dc5130bf4b4dd166e00705abdd018", + Author: "John Smith ", + Date: newTime("Tue Jul 11 22:26:11 2023 -0400"), + Message: strings.Builder{}, + Diffs: []Diff{}, + }, + // Empty commit. + { + Hash: "c904e0f5cd9f30ae520c66bd5f70806219fe7ca2", + Author: "John Smith ", + Date: newTime("Mon Jul 10 10:17:11 2023 -0400"), + Message: newStringBuilderValue("Empty Commit\n"), + Diffs: []Diff{}, + }, + { + Hash: "3d76a97faad96e0f326afb61c232b9c2a18dca35", + Author: "John Smith ", + Date: newTime("Tue Jul 11 18:03:54 2023 -0400"), + Message: strings.Builder{}, + Diffs: []Diff{ + { + PathB: "sample.txt", + LineStart: 1, + Content: *bytes.NewBuffer([]byte("Hello, world!\n")), + IsBinary: false, + }, + }, + }, + { + Hash: "df393b4125c2aa217211b2429b8963d0cefcee27", + Author: "Stephen ", + Date: newTime("Wed Dec 06 14:44:41 2017 -0800"), + Message: newStringBuilderValue("Add travis testing\n"), + Diffs: []Diff{ + { + PathB: ".gitignore", + LineStart: 1, + Content: *bytes.NewBuffer([]byte("\n\n\n**/__pycache__/\n**/*.pyc\n")), + IsBinary: false, + }, + { + PathB: ".travis.yml", + LineStart: 1, + Content: *bytes.NewBuffer([]byte(`language: python +python: + - "2.6" + - "2.7" + - "3.2" + - "3.3" + - "3.4" + - "3.5" + - "3.5-dev" # 3.5 development branch + - "3.6" + - "3.6-dev" # 3.6 development branch + - "3.7-dev" # 3.7 development branch + - "nightly" +`)), + IsBinary: false, + }, + }, + }, + { + Hash: "4218c39d99b5f30153f62471c1be1c1596f0a4d4", + Author: "Dustin Decker ", + Date: newTime("Thu Jan 13 12:02:24 2022 -0800"), + Message: newStringBuilderValue("Initial CLI w/ partially implemented Git source and demo detector (#1)\n"), + Diffs: []Diff{ + { + PathB: "Makefile", + LineStart: 1, + Content: *bytes.NewBuffer([]byte(`PROTOS_IMAGE=us-docker.pkg.dev/thog-artifacts/public/go-ci-1.17-1 + +.PHONY: check +.PHONY: test +.PHONY: test-race +.PHONY: run +.PHONY: install +.PHONY: protos +.PHONY: protos-windows +.PHONY: vendor + +install: + CGO_ENABLED=0 go install . + +check: + go fmt $(shell go list ./... | grep -v /vendor/) + go vet $(shell go list ./... | grep -v /vendor/) + +test: + CGO_ENABLED=0 go test $(shell go list ./... | grep -v /vendor/) + +test-race: + CGO_ENABLED=1 go test -race $(shell go list ./... | grep -v /vendor/) + +bench: + CGO_ENABLED=0 go test $(shell go list ./pkg/secrets/... | grep -v /vendor/) -benchmem -run=xxx -bench . + +run: + CGO_ENABLED=0 go run . git file://. + +protos: + docker run -u "$(shell id -u)" -v "$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))":/pwd "${PROTOS_IMAGE}" bash -c "cd /pwd; /pwd/scripts/gen_proto.sh" +`)), + IsBinary: false, + }, + }, + }, + { + Hash: "934cf5d255fd8e28b33f5a6ba64276caf0b284bf", + Author: "John Smith ", + Date: newTime("Tue Jul 11 18:43:22 2023 -0400"), + Message: newStringBuilderValue("Test toFile/plusLine parsing\n"), + Diffs: []Diff{ + { + PathB: "plusLine.txt", + LineStart: 1, + Content: *bytes.NewBuffer([]byte("-- test\n++ test\n\n")), + IsBinary: false, + }, + }, + }, + { + Hash: "2a5d703b02b52d65c65ee9f7928f158b919ab741", + Author: "Sergey Beryozkin ", + Date: newTime("Fri Jul 7 17:44:26 2023 +0100"), + Message: newStringBuilderValue("Do not refresh OIDC session if the user is requesting logout\n"), + Diffs: []Diff{ + { + PathB: "extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/BackChannelLogoutTokenCache.java", + LineStart: 45, + Content: *bytes.NewBuffer([]byte("\n\n public boolean containsTokenVerification(String token) {\n return cacheMap.containsKey(token);\n }\n\n\n\n\n")), + IsBinary: false, + }, + { + PathB: "extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/CodeAuthenticationMechanism.java", + LineStart: 1023, + Content: *bytes.NewBuffer([]byte("\n\n private boolean isRpInitiatedLogout(RoutingContext context, TenantConfigContext configContext) {\n\n\n")), + IsBinary: false, + }, + { + PathB: "extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/CodeAuthenticationMechanism.java", + LineStart: 1214, + Content: *bytes.NewBuffer([]byte("\n\n\n\n private class LogoutCall implements Function> {\n RoutingContext context;\n TenantConfigContext configContext;\n String idToken;\n\n LogoutCall(RoutingContext context, TenantConfigContext configContext, String idToken) {\n this.context = context;\n this.configContext = configContext;\n this.idToken = idToken;\n }\n\n @Override\n public Uni apply(SecurityIdentity identity) {\n if (isRpInitiatedLogout(context, configContext)) {\n LOG.debug(\"Performing an RP initiated logout\");\n fireEvent(SecurityEvent.Type.OIDC_LOGOUT_RP_INITIATED, identity);\n return buildLogoutRedirectUriUni(context, configContext, idToken);\n }\n if (isBackChannelLogoutPendingAndValid(configContext, identity)\n || isFrontChannelLogoutValid(context, configContext,\n identity)) {\n return removeSessionCookie(context, configContext.oidcConfig)\n .map(new Function() {\n @Override\n public Void apply(Void t) {\n throw new LogoutException();\n }\n });\n\n }\n return VOID_UNI;\n }\n }\n\n")), + IsBinary: false, + }, + { + PathB: "integration-tests/oidc-wiremock/src/main/resources/application.properties", + LineStart: 20, + Content: *bytes.NewBuffer([]byte("\n\n\nquarkus.oidc.code-flow.token.refresh-expired=true\nquarkus.oidc.code-flow.token.refresh-token-time-skew=5M\n\n\n")), + IsBinary: false, + }, + // WTF, shouldn't this be filtered out? + { + PathB: "integration-tests/oidc-wiremock/src/test/java/io/quarkus/it/keycloak/CodeFlowAuthorizationTest.java", + LineStart: 6, + Content: *bytes.NewBuffer([]byte("\n\n\n\n\n\n")), + IsBinary: false, + }, + { + PathB: "integration-tests/oidc-wiremock/src/test/java/io/quarkus/it/keycloak/CodeFlowAuthorizationTest.java", + LineStart: 76, + Content: *bytes.NewBuffer([]byte("\n\n // Logout\n\n\n\n")), + IsBinary: false, + }, + }, + }, + { + Hash: "2a057632d7f5fa3d1c77b9aa037263211c0e0290", + Author: "rjtmahinay ", + Date: newTime("Mon Jul 10 01:22:32 2023 +0800"), + Message: newStringBuilderValue("Add QuarkusApplication javadoc\n\n* Fix #34463\n"), + Diffs: []Diff{ + { + PathB: "core/runtime/src/main/java/io/quarkus/runtime/QuarkusApplication.java", + LineStart: 3, + Content: *bytes.NewBuffer([]byte("/**\n * This is usually used for command mode applications with a startup logic. The logic is executed inside\n * {@link QuarkusApplication#run} method before the main application exits.\n */\n")), + IsBinary: false, + }, + }, + }, + { + Hash: "bca2d17491015ea1522f34517223b5a366aea73c", + Author: "John Smith ", + Date: newTime("Tue Jul 11 18:12:21 2023 -0400"), + Message: newStringBuilderValue("Delete binary file\n"), + Diffs: []Diff{}, + }, + { + Hash: "afc6dc5d47f28366638da877ecb6b819c69e659b", + Author: "John Smith ", + Date: newTime("Mon Jul 10 12:21:33 2023 -0400"), + Message: newStringBuilderValue("Change binary file\n"), + Diffs: []Diff{}, + }, + { + Hash: "638595917417c5c8a956937b28c5127719023363", + Author: "John Smith ", + Date: newTime("Mon Jul 10 12:20:35 2023 -0400"), + Message: newStringBuilderValue("Add binary file\n"), + Diffs: []Diff{}, + }, + { + Hash: "ce0f5d1fe0272f180ccb660196f439c0c2f4ec8e", + Author: "John Smith ", + Date: newTime("Tue Jul 11 18:08:52 2023 -0400"), + Message: newStringBuilderValue("Delete file\n"), + Diffs: []Diff{}, + }, + { + Hash: "d606a729383371558473b70a6a7b1ca264b0d205", + Author: "John Smith ", + Date: newTime("Mon Jul 10 14:17:04 2023 -0400"), + Message: newStringBuilderValue("Rename file\n"), + Diffs: []Diff{}, + }, + { + Hash: "7bd16429f1f708746dabf970e54b05d2b4734997", + Author: "John Smith ", + Date: newTime("Tue Jul 11 18:10:49 2023 -0400"), + Message: newStringBuilderValue("Change file\n"), + Diffs: []Diff{ + { + PathB: "tzu", + LineStart: 11, + Content: *bytes.NewBuffer([]byte("\n\n\n\nSource: https://www.gnu.org/software/diffutils/manual/diffutils.html#An-Example-of-Unified-Format\n")), + IsBinary: false, + }, + }, + }, + { + Hash: "c7062674c17192caa284615ab2fa9778c6602164", + Author: "John Smith ", + Date: newTime("Mon Jul 10 10:15:18 2023 -0400"), + Message: newStringBuilderValue("Create files\n"), + Diffs: []Diff{ + { + PathB: "lao", + LineStart: 1, + Content: *bytes.NewBuffer([]byte("The Way that can be told of is not the eternal Way;\nThe name that can be named is not the eternal name.\nThe Nameless is the origin of Heaven and Earth;\nThe Named is the mother of all things.\nTherefore let there always be non-being,\n so we may see their subtlety,\nAnd let there always be being,\n so we may see their outcome.\nThe two are the same,\nBut after they are produced,\n they have different names.\n")), + IsBinary: false, + }, + { + PathB: "tzu", + LineStart: 1, + Content: *bytes.NewBuffer([]byte("The Nameless is the origin of Heaven and Earth;\nThe named is the mother of all things.\n\nTherefore let there always be non-being,\n so we may see their subtlety,\nAnd let there always be being,\n so we may see their outcome.\nThe two are the same,\nBut after they are produced,\n they have different names.\nThey both may be called deep and profound.\nDeeper and more profound,\nThe door of all subtleties!\n")), + IsBinary: false, + }, + }, + }, +} + +const stagedDiffs = `diff --git a/aws b/aws +index 2ee133b..12b4843 100644 +--- a/aws ++++ b/aws +@@ -1,7 +1,5 @@ +-blah blaj +- +-this is the secret: [Default] +-Access key Id: AKIAILE3JG6KMS3HZGCA +-Secret Access Key: 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 +- +-okay thank you bye ++[default] ++aws_access_key_id = AKIAXYZDQCEN4B6JSJQI ++aws_secret_access_key = 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 ++output = json ++region = us-east-2 + +diff --git a/aws2 b/aws2 +index 239b415..2ee133b 100644 +--- a/aws2 ++++ b/aws2 +@@ -1,5 +1,7 @@ + blah blaj + +-this is the secret: AKIA2E0A8F3B244C9986 ++this is the secret: [Default] ++Access key Id: AKIAILE3JG6KMS3HZGCA ++Secret Access Key: 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 + +-okay thank you bye +\ No newline at end of file ++okay thank you bye + +diff --git c/requirements.txt i/requirements.txt +new file mode 100644 +index 00000000..e69de29b + +diff --git a/core/runtime/src/main/java/io/quarkus/runtime/QuarkusApplication.java b/core/runtime/src/main/java/io/quarkus/runtime/QuarkusApplication.java +index 350685123d5..87d2220eb98 100644 +--- a/core/runtime/src/main/java/io/quarkus/runtime/QuarkusApplication.java ++++ b/core/runtime/src/main/java/io/quarkus/runtime/QuarkusApplication.java +@@ -2,0 +3,4 @@ ++/** ++ * This is usually used for command mode applications with a startup logic. The logic is executed inside ++ * {@link QuarkusApplication#run} method before the main application exits. ++ */ + +diff --git a/trufflehog_3.42.0_linux_arm64.tar.gz b/trufflehog_3.42.0_linux_arm64.tar.gz +new file mode 100644 +index 0000000..0a7a5b4 +Binary files /dev/null and b/trufflehog_3.42.0_linux_arm64.tar.gz differ + +diff --git a/lao b/lao +deleted file mode 100644 +index 635ef2c..0000000 +--- a/lao ++++ /dev/null +@@ -1,11 +0,0 @@ +-The Way that can be told of is not the eternal Way; +-The name that can be named is not the eternal name. +-The Nameless is the origin of Heaven and Earth; +-The Named is the mother of all things. +-Therefore let there always be non-being, +- so we may see their subtlety, +-And let there always be being, +- so we may see their outcome. +-The two are the same, +-But after they are produced, +- they have different names. + +diff --git a/tzu b/tzu.txt +similarity index 100% +rename from tzu +rename to tzu.txt + +diff --git a/tzu b/tzu +index 5af88a8..c729cdb 100644 +--- a/tzu ++++ b/tzu +@@ -11,3 +11,5 @@ But after they are produced, + They both may be called deep and profound. + Deeper and more profound, + The door of all subtleties! ++ ++Source: https://www.gnu.org/software/diffutils/manual/diffutils.html#An-Example-of-Unified-Format + +diff --git a/lao b/lao +new file mode 100644 +index 0000000..635ef2c +--- /dev/null ++++ b/lao +@@ -0,0 +1,11 @@ ++The Way that can be told of is not the eternal Way; ++The name that can be named is not the eternal name. ++The Nameless is the origin of Heaven and Earth; ++The Named is the mother of all things. ++Therefore let there always be non-being, ++ so we may see their subtlety, ++And let there always be being, ++ so we may see their outcome. ++The two are the same, ++But after they are produced, ++ they have different names. +diff --git a/tzu b/tzu +new file mode 100644 +index 0000000..5af88a8 +--- /dev/null ++++ b/tzu +@@ -0,0 +1,13 @@ ++The Nameless is the origin of Heaven and Earth; ++The named is the mother of all things. ++ ++Therefore let there always be non-being, ++ so we may see their subtlety, ++And let there always be being, ++ so we may see their outcome. ++The two are the same, ++But after they are produced, ++ they have different names. ++They both may be called deep and profound. ++Deeper and more profound, ++The door of all subtleties! +` const singleCommitMultiDiff = `commit 70001020fab32b1fcf2f1f0e5c66424eae649826 (HEAD -> master, origin/master, origin/HEAD) Author: Dustin Decker