PITTSBURGH (AP) Jeff Locke didn't think it made a difference who pitched. The Pittsburgh Pirates needed a win, and somebody was going to get it for them.
Still, it seemed a longshot that Locke would be the pitcher that cooled the majors' hottest team.
The left-handed Locke followed consecutive horrible starts with 6 2/3 scoreless innings, Erik Kratz hit his first home run since 2014 and the Pirates beat San Francisco 1-0 on Monday night, ending the Giants' eight-game winning streak.
Locke (6-5) allowed five hits, no walks and struck out three, helping the Pirates to just their second victory in 12 games. He had allowed 18 runs and 20 hits over 8 2/3 innings during his previous two outings.
''I really don't think it mattered who would have been on the mound tonight,'' Locke said. ''This team needed a win badly. Whoever pitched was going to go out, rise to the occasion and pitch a good game.
''I thought I threw the ball pretty well. I avoided the walks and was able to fill up the strike zone.''
Madison Bumgarner (8-3) was the tough-luck loser, allowing one run in eight innings while having his seven-game winning streak snapped. The left-hander had his 12th straight start allowing two earned runs or fewer and gave up five hits while striking out eight and walking two.
It was Bumgarner's second complete game of the season and 12th of his career.
''That's a tough one to lose for Bum,'' Giants manager Bruce Bochy said.
Kratz's solo shot with two outs in fifth was his first since a two-homer game for the Kansas City Royals on Aug. 18, 2014 against the Minnesota Twins.
The veteran catcher had been hitless in 16 at-bats since the Pirates acquired him from the Los Angeles Angels for $20,000 on June 11 after Francisco Cervelli went on the disabled list with a broken left hand.
''The nothing part of the score is why I came over here,'' Kratz said. ''We had four guys go out there and put up zeroes. That's more important than my one.''
Mark Melancon pitched the ninth in his 400th career appearance for his 20th save in 21 chances.
Left fielder Angel Pagan leaped and appeared to make a spectacular catch at the top of fence on Kratz's drive. However, the ball popped out of his glove when he crashed into the fence and fell into the first row of seats.
''I didn't think it was going to get out,'' Kratz said. ''I don't know if (Pagan) helped it over, but he didn't hurt it from going over, put it that way.''
Pagan slammed his glove down in frustration.
''It's a tough, tough play,'' Bumgarner said. ''As tough a play as an outfielder is going to have, really.''
Giants: 3B Matt Duffy (sore left Achilles tendon) sat out after playing in 188 consecutive games, which was the longest active streak in the major leagues, and Bochy said he will likely be placed on the disabled list Tuesday. ... CF Denard Span (stiff neck) got a night off but is expected to play Tuesday night.
Pirates: C Chris Stewart (sore left knee) sat out for the sixth time in eight games but said he should be able to play Tuesday. ... RHP Ryan Vogelsong (facial fractures) said his vision has returned to 20-20 after being struck in the left eye by a pitch May 23 and hopes to be activated from the 60-day disabled list July 23, the first day he is eligible. ... Pitching coach Ray Searage was sent home before the game with back spasms and a flare up of arthritis in his left wrist.
Giants: RHP Johnny Cueto (10-1, 2.10 ERA) looks to extend his seven-game winning streak when he starts Tuesday night. He is 18-4 with a 2.13 ERA against the Pirates in 28 career starts.
Pirates: RHP Wilfredo Boscan (1-0, 2.92) is expected to be recalled from Triple-A Indianapolis to make his first major league start in place of RHP Juan Nicasio, who was placed on the restricted list Saturday. Boscan made five relief appearances for the Pirates earlier this season, including his major league debut May 19.