@@ -226,18 +226,18 @@ func copyLibrary(dst, src string, library *config.LibraryState) error {
226226// changes.
227227// It uses the GitHub client to create a PR with the specified branch, title, and
228228// description to the repository.
229- func commitAndPush (ctx context.Context , r * generateRunner , commitMessage string ) error {
230- if ! r . cfg .Push {
229+ func commitAndPush (ctx context.Context , cfg * config. Config , repo gitrepo. Repository , ghClient GitHubClient , commitMessage string ) error {
230+ if ! cfg .Push {
231231 slog .Info ("Push flag is not specified, skipping" )
232232 return nil
233233 }
234234 // Ensure we have a GitHub repository
235- gitHubRepo , err := github .FetchGitHubRepoFromRemote (r . repo )
235+ gitHubRepo , err := github .FetchGitHubRepoFromRemote (repo )
236236 if err != nil {
237237 return err
238238 }
239239
240- status , err := r . repo .AddAll ()
240+ status , err := repo .AddAll ()
241241 if err != nil {
242242 return err
243243 }
@@ -249,25 +249,25 @@ func commitAndPush(ctx context.Context, r *generateRunner, commitMessage string)
249249 datetimeNow := formatTimestamp (time .Now ())
250250 branch := fmt .Sprintf ("librarian-%s" , datetimeNow )
251251 slog .Info ("Creating branch" , slog .String ("branch" , branch ))
252- if err := r . repo .CreateBranchAndCheckout (branch ); err != nil {
252+ if err := repo .CreateBranchAndCheckout (branch ); err != nil {
253253 return err
254254 }
255255
256256 // TODO: get correct language for message (https://github.com/googleapis/librarian/issues/885)
257257 slog .Info ("Committing" , "message" , commitMessage )
258- if err := r . repo .Commit (commitMessage ); err != nil {
258+ if err := repo .Commit (commitMessage ); err != nil {
259259 return err
260260 }
261261
262- if err := r . repo .Push (branch ); err != nil {
262+ if err := repo .Push (branch ); err != nil {
263263 return err
264264 }
265265
266266 // Create a new branch, set title and message for the PR.
267267 titlePrefix := "Librarian pull request"
268268 title := fmt .Sprintf ("%s: %s" , titlePrefix , datetimeNow )
269269 slog .Info ("Creating pull request" , slog .String ("branch" , branch ), slog .String ("title" , title ))
270- if _ , err = r . ghClient .CreatePullRequest (ctx , gitHubRepo , branch , title , commitMessage ); err != nil {
270+ if _ , err = ghClient .CreatePullRequest (ctx , gitHubRepo , branch , title , commitMessage ); err != nil {
271271 return fmt .Errorf ("failed to create pull request: %w" , err )
272272 }
273273 return nil
0 commit comments