mirror of
				https://github.com/taigrr/wtf
				synced 2025-01-18 04:03:14 -08:00 
			
		
		
		
	Simplified Github
This commit is contained in:
		
							parent
							
								
									7958b76b45
								
							
						
					
					
						commit
						e8d6d3e49b
					
				@ -40,7 +40,7 @@ wtf:
 | 
			
		||||
    repository: "/Users/chris/go/src/github.com/senorprogrammer/wtf"
 | 
			
		||||
  github:
 | 
			
		||||
    enabled: true
 | 
			
		||||
    organization: "BetterOfficeApps"
 | 
			
		||||
    owner: "BetterOfficeApps"
 | 
			
		||||
    position:
 | 
			
		||||
      top: 2
 | 
			
		||||
      left: 2
 | 
			
		||||
 | 
			
		||||
@ -21,13 +21,13 @@ func NewClient() *Client {
 | 
			
		||||
	return &client
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (client *Client) PullRequests(orgName string, repoName string) ([]*ghb.PullRequest, error) {
 | 
			
		||||
func (client *Client) PullRequests(owner string, repoName string) ([]*ghb.PullRequest, error) {
 | 
			
		||||
	oauthClient := client.oauthClient()
 | 
			
		||||
	github := ghb.NewClient(oauthClient)
 | 
			
		||||
 | 
			
		||||
	opts := &ghb.PullRequestListOptions{}
 | 
			
		||||
 | 
			
		||||
	prs, _, err := github.PullRequests.List(context.Background(), orgName, repoName, opts)
 | 
			
		||||
	prs, _, err := github.PullRequests.List(context.Background(), owner, repoName, opts)
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
@ -36,11 +36,11 @@ func (client *Client) PullRequests(orgName string, repoName string) ([]*ghb.Pull
 | 
			
		||||
	return prs, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (client *Client) Repository(orgName string, repoName string) (*ghb.Repository, error) {
 | 
			
		||||
func (client *Client) Repository(owner string, repoName string) (*ghb.Repository, error) {
 | 
			
		||||
	oauthClient := client.oauthClient()
 | 
			
		||||
	github := ghb.NewClient(oauthClient)
 | 
			
		||||
 | 
			
		||||
	repo, _, err := github.Repositories.Get(context.Background(), orgName, repoName)
 | 
			
		||||
	repo, _, err := github.Repositories.Get(context.Background(), owner, repoName)
 | 
			
		||||
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
 | 
			
		||||
@ -35,15 +35,9 @@ func (widget *Widget) Refresh() {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	client := NewClient()
 | 
			
		||||
	prs, _ := client.PullRequests(Config.UString("wtf.github.owner"), Config.UString("wtf.github.repo"))
 | 
			
		||||
 | 
			
		||||
	repo, _ := client.Repository(Config.UString("wtf.github.organization"), Config.UString("wtf.github.repo"))
 | 
			
		||||
	org := *repo.Organization
 | 
			
		||||
 | 
			
		||||
	prs, _ := client.PullRequests(Config.UString("wtf.github.organization"), Config.UString("wtf.github.repo"))
 | 
			
		||||
 | 
			
		||||
	title := fmt.Sprintf("[green]%s - %s[white]", *org.Login, *repo.Name)
 | 
			
		||||
 | 
			
		||||
	widget.View.SetTitle(fmt.Sprintf(" Github: %s ", title))
 | 
			
		||||
	widget.View.SetTitle(fmt.Sprintf(" Github: %s ", widget.title()))
 | 
			
		||||
	widget.RefreshedAt = time.Now()
 | 
			
		||||
 | 
			
		||||
	str := " [red]Open Review Requests[white]\n"
 | 
			
		||||
@ -113,3 +107,7 @@ func (widget *Widget) openPRs(prs []*ghb.PullRequest) string {
 | 
			
		||||
 | 
			
		||||
	return " [grey]none[white]\n"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (widget *Widget) title() string {
 | 
			
		||||
	return fmt.Sprintf("[green]%s - %s[white]", Config.UString("wtf.github.owner"), Config.UString("wtf.github.repo"))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										11
									
								
								wtf.go
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								wtf.go
									
									
									
									
									
								
							@ -57,6 +57,12 @@ var Config = wtf.LoadConfigFile()
 | 
			
		||||
func main() {
 | 
			
		||||
	wtf.Config = Config
 | 
			
		||||
 | 
			
		||||
	// Grid stores all the widgets onscreen (like an HTML table)
 | 
			
		||||
	grid := tview.NewGrid()
 | 
			
		||||
	grid.SetColumns(wtf.ToInts(Config.UList("wtf.grid.columns"))...)
 | 
			
		||||
	grid.SetRows(wtf.ToInts(Config.UList("wtf.grid.rows"))...)
 | 
			
		||||
	grid.SetBorder(false)
 | 
			
		||||
 | 
			
		||||
	// TODO: Really need to generalize all of these. This don't scale
 | 
			
		||||
	bamboohr.Config = Config
 | 
			
		||||
	bamboo := bamboohr.NewWidget()
 | 
			
		||||
@ -98,11 +104,6 @@ func main() {
 | 
			
		||||
	weather := weather.NewWidget()
 | 
			
		||||
	go wtf.Schedule(weather)
 | 
			
		||||
 | 
			
		||||
	grid := tview.NewGrid()
 | 
			
		||||
	grid.SetColumns(wtf.ToInts(Config.UList("wtf.grid.columns"))...)
 | 
			
		||||
	grid.SetRows(wtf.ToInts(Config.UList("wtf.grid.rows"))...)
 | 
			
		||||
	grid.SetBorder(false)
 | 
			
		||||
 | 
			
		||||
	addToApp(grid, bamboo)
 | 
			
		||||
	addToApp(grid, cal)
 | 
			
		||||
	addToApp(grid, git)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user