Skip to content

Commit

Permalink
update gitter room
Browse files Browse the repository at this point in the history
  • Loading branch information
coryb committed Aug 8, 2016
1 parent 704bce3 commit 4b822b1
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ src/github.com/mgutz/
src/github.com/op/
src/gopkg.in/
jira
jira.exe
jira.exe
schemas/*.json
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Join the chat at https://gitter.im/go-jira-cli/Lobby](https://badges.gitter.im/go-jira-cli/Lobby.svg)](https://gitter.im/go-jira-cli/Lobby?utm_source=badge&utm_medium=badge&utm_content=badge)
[![Join the chat at https://gitter.im/go-jira-cli/help](https://badges.gitter.im/go-jira-cli/help.svg)](https://gitter.im/go-jira-cli/help?utm_source=badge&utm_medium=badge&utm_content=badge)

# go-jira
simple command line client for Atlassian's Jira service written in Go
Expand Down
26 changes: 25 additions & 1 deletion commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package jira

import (
"bytes"
"encoding/json"
"errors"
"fmt"
"github.com/howeyc/gopass"
"github.com/Netflix-Skunkworks/go-jira/data"
"io/ioutil"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -261,8 +264,29 @@ func (c *Cli) CmdComponents(project string) error {
return runTemplate(c.getTemplate("components"), data, nil)
}

func (c *Cli) ValidTransitions(issue string) (jiradata.Transitions,error) {
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/transitions?expand=transitions.fields", c.endpoint, issue)
resp, err := c.get(uri)
if err != nil {
return nil, err
}

transMeta := &jiradata.TransitionsMeta{}
content, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
err = json.Unmarshal(content, transMeta)
if err != nil {
return nil, err
}

return transMeta.Transitions, nil
}

func (c *Cli) CmdTransitions(issue string) error {
log.Debugf("Transitions called")
// FIXME this should just call ValidTransitions then pass that data to templates
c.Browse(issue)
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/transitions", c.endpoint, issue)
data, err := responseToJson(c.get(uri))
Expand Down Expand Up @@ -565,7 +589,7 @@ func (c *Cli) CmdTransition(issue string, trans string) error {
}
if transId == "" {
err := fmt.Errorf("Invalid Transition '%s', Available: %s", trans, strings.Join(found, ", "))
log.Errorf("%s", err)
log.Debugf("%s", err)
return err
}

Expand Down
13 changes: 12 additions & 1 deletion main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,18 @@ Command Options:
requireArgs(2)
if err = c.CmdDups(args[0], args[1]); err == nil {
opts["resolution"] = "Duplicate"
err = c.CmdTransition(args[0], "close")
trans, err := c.ValidTransitions(args[0])
if err == nil {
close := trans.Find("close")
if close != nil {
err = c.CmdTransition(args[0], "close")
} else {
// for now just assume if there is no "close", then
// there is a "done" state
err = c.CmdTransition(args[0], "done")
}
}

}
case "watch":
requireArgs(1)
Expand Down
21 changes: 21 additions & 0 deletions schemas/fetch-schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python
from lxml import html
import requests
import json

page = requests.get('https://docs.atlassian.com/jira/REST/cloud')
tree = html.fromstring(page.content)

schemas = tree.xpath("//div[@class='representation-doc-block']//code/text()")

for schema in schemas:
try:
data = json.loads(schema)
if "title" in data:
title = data["title"].replace(" ", "")
print "Writing {}.json".format(title)
with open("{}.json".format(title), 'w') as f:
f.write(schema)
except:
True

6 changes: 5 additions & 1 deletion t/000setup.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ eval "$(curl -q -s https://raw.githubusercontent.com/coryb/osht/master/osht.sh)"
cd $(dirname $0)
jira="../jira --user admin"

PLAN 13
PLAN 14

# clean out any old containers
RUNS sh -c "docker rm -f go-jira-test || true"
Expand Down Expand Up @@ -42,3 +42,7 @@ RUNS $jira req -M POST /rest/api/2/project '{"key":"PROCESS","name":"Process","p
RUNS $jira req -M POST /rest/api/2/project '{"key":"TASK","name":"Task","projectTypeKey":"business","projectTemplateKey":"com.atlassian.jira-core-project-templates:jira-core-task-management","lead":"gojira"}'

RUNS $jira logout

# export new templates so we are always using whatever is latest
# and not whatever is in the test-runners homedir
RUNS $jira export-templates -d .jira.d/templates

0 comments on commit 4b822b1

Please sign in to comment.