Skip to content

Commit b7f5023

Browse files
author
James Wilson
committed
Merge branch 'master' of github.com:flightaware/tcl-jira-api
2 parents df70ca5 + e452dc8 commit b7f5023

File tree

2 files changed

+21
-27
lines changed

2 files changed

+21
-27
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ install-package: pkgIndex
3030
@install -o $(UID) -g $(GID) -m 0755 -d $(TARGET)
3131
@echo " Copying package Tcl files"
3232
@install -o $(UID) -g $(GID) -m 0644 package/*.tcl $(TARGET)
33-
@sed -i '' -e's/tclsh.\../$(TCLSH)/' $(TARGET)/*
3433
@echo "Installation complete"
3534

3635
make uninstall-package:

package/main.tcl

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ namespace eval ::jira {
224224
$postdata map_open string body string $argarray(body)
225225

226226
$postdata map_key author map_open
227-
$postdata map_key name string $author(name)
227+
$postdata map_key name string $author(displayName)
228228
$postdata map_close
229229

230230
$postdata map_close
@@ -414,14 +414,14 @@ namespace eval ::jira {
414414
}
415415

416416
#
417-
# Given an issue identifier (eg ("JIRA-123") and a username, assign the issue
418-
# to the user. To unassign an issue, pass the username as an empty string.
417+
# Given an issue identifier (eg ("JIRA-123") and a JIRA account ID, assign the issue
418+
# to the user. To unassign an issue, pass the account ID as an empty string.
419419
# Returns 0 or 1 indicating whether the assignment was successful, and any
420420
# data returned from the API endpoint is stored in _result.
421421
#
422422
# See https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-assign
423423
#
424-
proc assignIssue {issueID username _result} {
424+
proc assignIssue {issueID accountId _result} {
425425
upvar 1 $_result result
426426
unset -nocomplain result
427427

@@ -431,10 +431,10 @@ namespace eval ::jira {
431431

432432
$postdata map_open
433433

434-
if {$username eq ""} {
435-
$postdata map_key name null
434+
if {$accountId eq ""} {
435+
$postdata map_key accountId null
436436
} else {
437-
$postdata map_key name string $username
437+
$postdata map_key accountId string $accountId
438438
}
439439

440440
$postdata map_close
@@ -503,24 +503,15 @@ namespace eval ::jira {
503503
return 0
504504
}
505505
}
506-
507-
#
508-
# Given a username (eg "fred"), get user data and store in _result
506+
509507
#
510-
# See https://docs.atlassian.com/jira/REST/cloud/#api/2/user-getUser
508+
# Get info on the currenty-logged-in user. User data will be stored in _result.
511509
#
512-
proc getUser {key _result args} {
513-
::jira::parse_args args argarray
510+
proc getCurrentUser {_result} {
514511
upvar 1 $_result result
515512
unset -nocomplain result
516-
517-
if {$key == ""} {
518-
set url "[::jira::baseurl]/rest/api/2/myself"
519-
} else {
520-
set url "[::jira::baseurl]/rest/api/2/user?username=$key"
521-
}
522-
523-
513+
514+
set url "[::jira::baseurl]/rest/api/2/myself"
524515
if {[::jira::raw $url GET json]} {
525516
array set result [::yajl::json2dict $json(data)]
526517
return 1
@@ -541,7 +532,7 @@ namespace eval ::jira {
541532
upvar 1 $_result result
542533
unset -nocomplain result
543534

544-
set url "[::jira::baseurl]/rest/api/2/user/search?username=$email"
535+
set url "[::jira::baseurl]/rest/api/2/user/search?query=$email"
545536

546537
if {[::jira::raw $url GET json]} {
547538
set rawdata [::yajl::json2dict $json(data)]
@@ -806,7 +797,7 @@ namespace eval ::jira {
806797
#
807798
# Parse user JSON and generate basic BasicUser JSON.
808799
#
809-
proc parseBasicUser {key _result args} {
800+
proc parseBasicUser {email _result args} {
810801
::jira::parse_args args argarray
811802

812803
upvar 1 $_result result
@@ -816,10 +807,14 @@ namespace eval ::jira {
816807
array set result $argarray(userDefinition)
817808
return
818809
}
810+
811+
if {$email eq ""} {
812+
::jira::getCurrentUser getUserResult
813+
} else {
814+
::jira::getUserByEmail $email getUserResult
815+
}
819816

820-
::jira::getUser $key getUserResult
821-
822-
set keyMap [list self name displayName active]
817+
set keyMap [list self displayName active]
823818

824819
foreach key $keyMap {
825820
set result($key) $getUserResult($key)

0 commit comments

Comments
 (0)