Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #258 from nkubala/release_pull_requests
Browse files Browse the repository at this point in the history
Add script to list all pull requests for each release
  • Loading branch information
nkubala authored Oct 1, 2018
2 parents 4db9345 + cb244d1 commit 8f75ae0
Show file tree
Hide file tree
Showing 144 changed files with 52,720 additions and 0 deletions.
53 changes: 53 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions hack/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2018 Google, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

# you can pass your github token with --token here if you run out of requests
go run ${DIR}/release_notes/listpullreqs.go

echo "Huge thank you for this release towards our contributors: "
git log "$(git describe --abbrev=0)".. --format="%aN" --reverse | sort | uniq | awk '{printf "- %s\n", $0 }'
98 changes: 98 additions & 0 deletions hack/release_notes/listpullreqs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
Copyright 2018 Google, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
"context"
"fmt"

"github.com/google/go-github/github"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"golang.org/x/oauth2"
)

var (
token string
fromTag string
toTag string
)

var rootCmd = &cobra.Command{
Use: "listpullreqs fromTag toTag",
Short: "Lists pull requests between two versions in our changelog markdown format",
ArgAliases: []string{"fromTag", "toTag"},
Run: func(cmd *cobra.Command, args []string) {
printPullRequests()
},
}

const org = "GoogleContainerTools"
const repo = "container-diff"

func main() {
rootCmd.Flags().StringVar(&token, "token", "", "Specify personal Github Token if you are hitting a rate limit anonymously. https://github.com/settings/tokens")
rootCmd.Flags().StringVar(&fromTag, "fromTag", "", "comparison of commits is based on this tag (defaults to the latest tag in the repo)")
rootCmd.Flags().StringVar(&toTag, "toTag", "master", "this is the commit that is compared with fromTag")
if err := rootCmd.Execute(); err != nil {
logrus.Fatal(err)
}
}

func printPullRequests() {
client := getClient()

releases, _, _ := client.Repositories.ListReleases(context.Background(), org, repo, &github.ListOptions{})
lastReleaseTime := *releases[0].PublishedAt
fmt.Println(fmt.Sprintf("Collecting pull request that were merged since the last release: %s (%s)", *releases[0].TagName, lastReleaseTime))

listSize := 1
for page := 0; listSize > 0; page++ {
pullRequests, _, _ := client.PullRequests.List(context.Background(), org, repo, &github.PullRequestListOptions{
State: "closed",
Sort: "updated",
Direction: "desc",
ListOptions: github.ListOptions{
PerPage: 100,
Page: page,
},
})

for idx := range pullRequests {
pr := pullRequests[idx]
if pr.MergedAt != nil {
if pr.GetMergedAt().After(lastReleaseTime.Time) {
fmt.Printf("* %s [#%d](https://github.com/%s/%s/pull/%d)\n", pr.GetTitle(), *pr.Number, org, repo, *pr.Number)
}
}
}

listSize = len(pullRequests)
}
}

func getClient() *github.Client {
if len(token) <= 0 {
return github.NewClient(nil)
}
ctx := context.Background()
ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: token},
)
tc := oauth2.NewClient(ctx, ts)
return github.NewClient(tc)
}
3 changes: 3 additions & 0 deletions vendor/github.com/golang/protobuf/AUTHORS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/github.com/golang/protobuf/CONTRIBUTORS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions vendor/github.com/golang/protobuf/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8f75ae0

Please sign in to comment.