diff --git a/app/.jshintrc b/app/.jshintrc index 26b6a1f0..767b6edf 100644 --- a/app/.jshintrc +++ b/app/.jshintrc @@ -17,7 +17,8 @@ "Tooltip", "Drop", "Dropzone", - "dragula" + "dragula", + "datetimepicker" ], "browser": true, "boss": true, diff --git a/app/app/components/section/github/type-editor.js b/app/app/components/section/github/type-editor.js index 12b95d13..c8171da7 100644 --- a/app/app/components/section/github/type-editor.js +++ b/app/app/components/section/github/type-editor.js @@ -25,8 +25,12 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, noRepos: false, showCommits: false, showIssueNum: false, + showLabels: false, didReceiveAttrs() { + $.datetimepicker.setLocale('en'); + $('#branch-since').datetimepicker(); + let self = this; let page = this.get('page'); @@ -48,7 +52,7 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, branch: "", branchURL: "", branchSince: "", - branchLines: 30, + branchLines: "30", issueNum: "1" }; @@ -58,6 +62,9 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, config.repo = metaConfig.repo; config.report = metaConfig.report; config.lists = metaConfig.lists; + config.branchSince = metaConfig.branchSince; + config.branchLines = metaConfig.branchLines; + config.issueNum = metaConfig.issueNum; } catch (e) {} self.set('config', config); @@ -86,7 +93,6 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, this.destroyTooltips(); }, - getOwnerLists() { this.set('busy', true); @@ -95,8 +101,6 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, let thisOwner = this.get('config.owner'); let page = this.get('page'); - console.log("owner", thisOwner); - if (is.null(thisOwner) || is.undefined(thisOwner)) { if (owners.length) { thisOwner = owners[0]; @@ -127,8 +131,6 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, let repos = this.get('repos'); let thisRepo = this.get('config.repo'); - console.log("repo", thisRepo); - if (is.null(repos) || is.undefined(repos) || repos.length === 0) { this.set('noRepos', true); return; @@ -170,8 +172,6 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, let thisReport = this.get('config.report'); - console.log("report", thisReport); - if (is.null(thisReport) || is.undefined(thisReport)) { thisReport = reports[0]; this.set('config.report', thisReport); @@ -186,7 +186,14 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, }, renderSwitch(thisReport) { + + let bl = this.get('config.branchLines'); + if (is.undefined(bl) || bl === "" || bl <= 0) { + this.set('config.branchLines', "30"); + } + this.set('showCommits', false); + this.set('showLabels', false); this.set('showIssueNum', false); switch (thisReport.id) { case 'commits_data': @@ -194,8 +201,8 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, this.getBranchLists(); break; case "issues_data": - // nothing to show yet - this.set('busy', false); + this.set('showLabels', true); + this.getLabelLists(); break; case "issuenum_data": this.set('showIssueNum', true); @@ -207,8 +214,6 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, getBranchLists() { this.set('busy', true); - console.log("branches"); - let self = this; let page = this.get('page'); @@ -223,8 +228,11 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, let noIncluded = true; lists.forEach(function(list) { - let saved = savedLists.findBy("id", list.id); let included = false; + var saved; + if (is.not.undefined(savedLists)) { + saved = savedLists.findBy("id", list.id); + } if (is.not.undefined(saved)) { included = saved.included; noIncluded = false; @@ -247,6 +255,43 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, }); }, + getLabelLists() { + this.set('busy', true); + + let self = this; + let page = this.get('page'); + + this.get('sectionService').fetch(page, "labels", self.get('config')) + .then(function(lists) { + let savedLists = self.get('config.lists'); + if (savedLists === null) { + savedLists = []; + } + + if (lists.length > 0) { + lists.forEach(function(list) { + var saved; + if (is.not.undefined(savedLists)) { + saved = savedLists.findBy("id", list.id); + } + let included = false; + if (is.not.undefined(saved)) { + included = saved.included; + } + list.included = included; + }); + } + + self.set('config.lists', lists); + self.set('busy', false); + }, function(error) { //jshint ignore: line + self.set('busy', false); + self.set('authenticated', false); + self.showNotification("Unable to fetch repository labels"); + console.log(error); + }); + }, + actions: { isDirty() { return this.get('isDirty'); @@ -266,6 +311,21 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, } }, + onLabelCheckbox(id) { + let lists = this.get('config.lists'); + let list = lists.findBy('id', id); + + // restore the list of branches to the default state + // lists.forEach(function(lst) { + // Ember.set(lst, 'included', false); + // }); + + if (list !== null) { + Ember.set(list, 'included', !list.included); + } + }, + + authStage2() { let self = this; self.set('authenticated', true); @@ -319,6 +379,10 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, this.getReportLists(); }, + checkLinesChange(thisLines) { + console.log("onLinesChange", thisLines); + }, + onCancel() { this.attrs.onCancel(); }, @@ -326,6 +390,15 @@ export default Ember.Component.extend(SectionMixin, NotifierMixin, TooltipMixin, onAction(title) { this.set('busy', true); + let thisLines = this.get('config.branchLines'); + if (is.undefined(thisLines) || thisLines === "") { + this.set('config.branchLines', 30); + } else if (thisLines < 1) { + this.set('config.branchLines', 1); + } else if (thisLines > 100) { + this.set('config.branchLines', 100); + } + let self = this; let page = this.get('page'); let meta = this.get('meta'); diff --git a/app/app/styles/vendor.scss b/app/app/styles/vendor.scss index 5439517b..75a90459 100644 --- a/app/app/styles/vendor.scss +++ b/app/app/styles/vendor.scss @@ -29,3 +29,574 @@ filter: alpha(opacity=20); } /* FINISH dragula.js */ + +/* START jquery.datetimepicker.full.min.js */ +.xdsoft_datetimepicker { + box-shadow: 0 5px 15px -5px rgba(0, 0, 0, 0.506); + background: #fff; + border-bottom: 1px solid #bbb; + border-left: 1px solid #ccc; + border-right: 1px solid #ccc; + border-top: 1px solid #ccc; + color: #333; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + padding: 8px; + padding-left: 0; + padding-top: 2px; + position: absolute; + z-index: 9999; + -moz-box-sizing: border-box; + box-sizing: border-box; + display: none; +} +.xdsoft_datetimepicker.xdsoft_rtl { + padding: 8px 0 8px 8px; +} + +.xdsoft_datetimepicker iframe { + position: absolute; + left: 0; + top: 0; + width: 75px; + height: 210px; + background: transparent; + border: none; +} + +/*For IE8 or lower*/ +.xdsoft_datetimepicker button { + border: none !important; +} + +.xdsoft_noselect { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + -o-user-select: none; + user-select: none; +} + +.xdsoft_noselect::selection { background: transparent } +.xdsoft_noselect::-moz-selection { background: transparent } + +.xdsoft_datetimepicker.xdsoft_inline { + display: inline-block; + position: static; + box-shadow: none; +} + +.xdsoft_datetimepicker * { + -moz-box-sizing: border-box; + box-sizing: border-box; + padding: 0; + margin: 0; +} + +.xdsoft_datetimepicker .xdsoft_datepicker, .xdsoft_datetimepicker .xdsoft_timepicker { + display: none; +} + +.xdsoft_datetimepicker .xdsoft_datepicker.active, .xdsoft_datetimepicker .xdsoft_timepicker.active { + display: block; +} + +.xdsoft_datetimepicker .xdsoft_datepicker { + width: 224px; + float: left; + margin-left: 8px; +} +.xdsoft_datetimepicker.xdsoft_rtl .xdsoft_datepicker { + float: right; + margin-right: 8px; + margin-left: 0; +} + +.xdsoft_datetimepicker.xdsoft_showweeks .xdsoft_datepicker { + width: 256px; +} + +.xdsoft_datetimepicker .xdsoft_timepicker { + width: 58px; + float: left; + text-align: center; + margin-left: 8px; + margin-top: 0; +} +.xdsoft_datetimepicker.xdsoft_rtl .xdsoft_timepicker { + float: right; + margin-right: 8px; + margin-left: 0; +} + +.xdsoft_datetimepicker .xdsoft_datepicker.active+.xdsoft_timepicker { + margin-top: 8px; + margin-bottom: 3px +} + +.xdsoft_datetimepicker .xdsoft_monthpicker { + position: relative; + text-align: center; +} + +.xdsoft_datetimepicker .xdsoft_label i, +.xdsoft_datetimepicker .xdsoft_prev, +.xdsoft_datetimepicker .xdsoft_next, +.xdsoft_datetimepicker .xdsoft_today_button { + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAAAeCAYAAADaW7vzAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6Q0NBRjI1NjM0M0UwMTFFNDk4NkFGMzJFQkQzQjEwRUIiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6Q0NBRjI1NjQ0M0UwMTFFNDk4NkFGMzJFQkQzQjEwRUIiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpDQ0FGMjU2MTQzRTAxMUU0OTg2QUYzMkVCRDNCMTBFQiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpDQ0FGMjU2MjQzRTAxMUU0OTg2QUYzMkVCRDNCMTBFQiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PoNEP54AAAIOSURBVHja7Jq9TsMwEMcxrZD4WpBYeKUCe+kTMCACHZh4BFfHO/AAIHZGFhYkBBsSEqxsLCAgXKhbXYOTxh9pfJVP+qutnZ5s/5Lz2Y5I03QhWji2GIcgAokWgfCxNvcOCCGKqiSqhUp0laHOne05vdEyGMfkdxJDVjgwDlEQgYQBgx+ULJaWSXXS6r/ER5FBVR8VfGftTKcITNs+a1XpcFoExREIDF14AVIFxgQUS+h520cdud6wNkC0UBw6BCO/HoCYwBhD8QCkQ/x1mwDyD4plh4D6DDV0TAGyo4HcawLIBBSLDkHeH0Mg2yVP3l4TQMZQDDsEOl/MgHQqhMNuE0D+oBh0CIr8MAKyazBH9WyBuKxDWgbXfjNf32TZ1KWm/Ap1oSk/R53UtQ5xTh3LUlMmT8gt6g51Q9p+SobxgJQ/qmsfZhWywGFSl0yBjCLJCMgXail3b7+rumdVJ2YRss4cN+r6qAHDkPWjPjdJCF4n9RmAD/V9A/Wp4NQassDjwlB6XBiCxcJQWmZZb8THFilfy/lfrTvLghq2TqTHrRMTKNJ0sIhdo15RT+RpyWwFdY96UZ/LdQKBGjcXpcc1AlSFEfLmouD+1knuxBDUVrvOBmoOC/rEcN7OQxKVeJTCiAdUzUJhA2Oez9QTkp72OTVcxDcXY8iKNkxGAJXmJCOQwOa6dhyXsOa6XwEGAKdeb5ET3rQdAAAAAElFTkSuQmCC); +} + +.xdsoft_datetimepicker .xdsoft_label i { + opacity: 0.5; + background-position: -92px -19px; + display: inline-block; + width: 9px; + height: 20px; + vertical-align: middle; +} + +.xdsoft_datetimepicker .xdsoft_prev { + float: left; + background-position: -20px 0; +} +.xdsoft_datetimepicker .xdsoft_today_button { + float: left; + background-position: -70px 0; + margin-left: 5px; +} + +.xdsoft_datetimepicker .xdsoft_next { + float: right; + background-position: 0 0; +} + +.xdsoft_datetimepicker .xdsoft_next, +.xdsoft_datetimepicker .xdsoft_prev , +.xdsoft_datetimepicker .xdsoft_today_button { + background-color: transparent; + background-repeat: no-repeat; + border: 0 none; + cursor: pointer; + display: block; + height: 30px; + opacity: 0.5; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; + outline: medium none; + overflow: hidden; + padding: 0; + position: relative; + text-indent: 100%; + white-space: nowrap; + width: 20px; + min-width: 0; +} + +.xdsoft_datetimepicker .xdsoft_timepicker .xdsoft_prev, +.xdsoft_datetimepicker .xdsoft_timepicker .xdsoft_next { + float: none; + background-position: -40px -15px; + height: 15px; + width: 30px; + display: block; + margin-left: 14px; + margin-top: 7px; +} +.xdsoft_datetimepicker.xdsoft_rtl .xdsoft_timepicker .xdsoft_prev, +.xdsoft_datetimepicker.xdsoft_rtl .xdsoft_timepicker .xdsoft_next { + float: none; + margin-left: 0; + margin-right: 14px; +} + +.xdsoft_datetimepicker .xdsoft_timepicker .xdsoft_prev { + background-position: -40px 0; + margin-bottom: 7px; + margin-top: 0; +} + +.xdsoft_datetimepicker .xdsoft_timepicker .xdsoft_time_box { + height: 151px; + overflow: hidden; + border-bottom: 1px solid #ddd; +} + +.xdsoft_datetimepicker .xdsoft_timepicker .xdsoft_time_box >div >div { + background: #f5f5f5; + border-top: 1px solid #ddd; + color: #666; + font-size: 12px; + text-align: center; + border-collapse: collapse; + cursor: pointer; + border-bottom-width: 0; + height: 25px; + line-height: 25px; +} + +.xdsoft_datetimepicker .xdsoft_timepicker .xdsoft_time_box >div > div:first-child { + border-top-width: 0; +} + +.xdsoft_datetimepicker .xdsoft_today_button:hover, +.xdsoft_datetimepicker .xdsoft_next:hover, +.xdsoft_datetimepicker .xdsoft_prev:hover { + opacity: 1; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; +} + +.xdsoft_datetimepicker .xdsoft_label { + display: inline; + position: relative; + z-index: 9999; + margin: 0; + padding: 5px 3px; + font-size: 14px; + line-height: 20px; + font-weight: bold; + background-color: #fff; + float: left; + width: 182px; + text-align: center; + cursor: pointer; +} + +.xdsoft_datetimepicker .xdsoft_label:hover>span { + text-decoration: underline; +} + +.xdsoft_datetimepicker .xdsoft_label:hover i { + opacity: 1.0; +} + +.xdsoft_datetimepicker .xdsoft_label > .xdsoft_select { + border: 1px solid #ccc; + position: absolute; + right: 0; + top: 30px; + z-index: 101; + display: none; + background: #fff; + max-height: 160px; + overflow-y: hidden; +} + +.xdsoft_datetimepicker .xdsoft_label > .xdsoft_select.xdsoft_monthselect{ right: -7px } +.xdsoft_datetimepicker .xdsoft_label > .xdsoft_select.xdsoft_yearselect{ right: 2px } +.xdsoft_datetimepicker .xdsoft_label > .xdsoft_select > div > .xdsoft_option:hover { + color: #fff; + background: #ff8000; +} + +.xdsoft_datetimepicker .xdsoft_label > .xdsoft_select > div > .xdsoft_option { + padding: 2px 10px 2px 5px; + text-decoration: none !important; +} + +.xdsoft_datetimepicker .xdsoft_label > .xdsoft_select > div > .xdsoft_option.xdsoft_current { + background: #33aaff; + box-shadow: #178fe5 0 1px 3px 0 inset; + color: #fff; + font-weight: 700; +} + +.xdsoft_datetimepicker .xdsoft_month { + width: 100px; + text-align: right; +} + +.xdsoft_datetimepicker .xdsoft_calendar { + clear: both; +} + +.xdsoft_datetimepicker .xdsoft_year{ + width: 48px; + margin-left: 5px; +} + +.xdsoft_datetimepicker .xdsoft_calendar table { + border-collapse: collapse; + width: 100%; + +} + +.xdsoft_datetimepicker .xdsoft_calendar td > div { + padding-right: 5px; +} + +.xdsoft_datetimepicker .xdsoft_calendar th { + height: 25px; +} + +.xdsoft_datetimepicker .xdsoft_calendar td,.xdsoft_datetimepicker .xdsoft_calendar th { + width: 14.2857142%; + background: #f5f5f5; + border: 1px solid #ddd; + color: #666; + font-size: 12px; + text-align: right; + vertical-align: middle; + padding: 0; + border-collapse: collapse; + cursor: pointer; + height: 25px; +} +.xdsoft_datetimepicker.xdsoft_showweeks .xdsoft_calendar td,.xdsoft_datetimepicker.xdsoft_showweeks .xdsoft_calendar th { + width: 12.5%; +} + +.xdsoft_datetimepicker .xdsoft_calendar th { + background: #f1f1f1; +} + +.xdsoft_datetimepicker .xdsoft_calendar td.xdsoft_today { + color: #33aaff; +} + +.xdsoft_datetimepicker .xdsoft_calendar td.xdsoft_highlighted_default { + background: #ffe9d2; + box-shadow: #ffb871 0 1px 4px 0 inset; + color: #000; +} +.xdsoft_datetimepicker .xdsoft_calendar td.xdsoft_highlighted_mint { + background: #c1ffc9; + box-shadow: #00dd1c 0 1px 4px 0 inset; + color: #000; +} + +.xdsoft_datetimepicker .xdsoft_calendar td.xdsoft_default, +.xdsoft_datetimepicker .xdsoft_calendar td.xdsoft_current, +.xdsoft_datetimepicker .xdsoft_timepicker .xdsoft_time_box >div >div.xdsoft_current { + background: #33aaff; + box-shadow: #178fe5 0 1px 3px 0 inset; + color: #fff; + font-weight: 700; +} + +.xdsoft_datetimepicker .xdsoft_calendar td.xdsoft_other_month, +.xdsoft_datetimepicker .xdsoft_calendar td.xdsoft_disabled, +.xdsoft_datetimepicker .xdsoft_time_box >div >div.xdsoft_disabled { + opacity: 0.5; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; + cursor: default; +} + +.xdsoft_datetimepicker .xdsoft_calendar td.xdsoft_other_month.xdsoft_disabled { + opacity: 0.2; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=20)"; +} + +.xdsoft_datetimepicker .xdsoft_calendar td:hover, +.xdsoft_datetimepicker .xdsoft_timepicker .xdsoft_time_box >div >div:hover { + color: #fff !important; + background: #ff8000 !important; + box-shadow: none !important; +} + +.xdsoft_datetimepicker .xdsoft_calendar td.xdsoft_current.xdsoft_disabled:hover, +.xdsoft_datetimepicker .xdsoft_timepicker .xdsoft_time_box>div>div.xdsoft_current.xdsoft_disabled:hover { + background: #33aaff !important; + box-shadow: #178fe5 0 1px 3px 0 inset !important; + color: #fff !important; +} + +.xdsoft_datetimepicker .xdsoft_calendar td.xdsoft_disabled:hover, +.xdsoft_datetimepicker .xdsoft_timepicker .xdsoft_time_box >div >div.xdsoft_disabled:hover { + color: inherit !important; + background: inherit !important; + box-shadow: inherit !important; +} + +.xdsoft_datetimepicker .xdsoft_calendar th { + font-weight: 700; + text-align: center; + color: #999; + cursor: default; +} + +.xdsoft_datetimepicker .xdsoft_copyright { + color: #ccc !important; + font-size: 10px; + clear: both; + float: none; + margin-left: 8px; +} + +.xdsoft_datetimepicker .xdsoft_copyright a { color: #eee !important } +.xdsoft_datetimepicker .xdsoft_copyright a:hover { color: #aaa !important } + +.xdsoft_time_box { + position: relative; + border: 1px solid #ccc; +} +.xdsoft_scrollbar >.xdsoft_scroller { + background: #ccc !important; + height: 20px; + border-radius: 3px; +} +.xdsoft_scrollbar { + position: absolute; + width: 7px; + right: 0; + top: 0; + bottom: 0; + cursor: pointer; +} +.xdsoft_datetimepicker.xdsoft_rtl .xdsoft_scrollbar { + left: 0; + right: auto; +} +.xdsoft_scroller_box { + position: relative; +} + +.xdsoft_datetimepicker.xdsoft_dark { + box-shadow: 0 5px 15px -5px rgba(255, 255, 255, 0.506); + background: #000; + border-bottom: 1px solid #444; + border-left: 1px solid #333; + border-right: 1px solid #333; + border-top: 1px solid #333; + color: #ccc; +} + +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_timepicker .xdsoft_time_box { + border-bottom: 1px solid #222; +} +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_timepicker .xdsoft_time_box >div >div { + background: #0a0a0a; + border-top: 1px solid #222; + color: #999; +} + +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_label { + background-color: #000; +} +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_label > .xdsoft_select { + border: 1px solid #333; + background: #000; +} + +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_label > .xdsoft_select > div > .xdsoft_option:hover { + color: #000; + background: #007fff; +} + +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_label > .xdsoft_select > div > .xdsoft_option.xdsoft_current { + background: #cc5500; + box-shadow: #b03e00 0 1px 3px 0 inset; + color: #000; +} + +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_label i, +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_prev, +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_next, +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_today_button { + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAAAeCAYAAADaW7vzAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6QUExQUUzOTA0M0UyMTFFNDlBM0FFQTJENTExRDVBODYiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6QUExQUUzOTE0M0UyMTFFNDlBM0FFQTJENTExRDVBODYiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpBQTFBRTM4RTQzRTIxMUU0OUEzQUVBMkQ1MTFENUE4NiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpBQTFBRTM4RjQzRTIxMUU0OUEzQUVBMkQ1MTFENUE4NiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pp0VxGEAAAIASURBVHja7JrNSgMxEMebtgh+3MSLr1T1Xn2CHoSKB08+QmR8Bx9A8e7RixdB9CKCoNdexIugxFlJa7rNZneTbLIpM/CnNLsdMvNjM8l0mRCiQ9Ye61IKCAgZAUnH+mU3MMZaHYChBnJUDzWOFZdVfc5+ZFLbrWDeXPwbxIqrLLfaeS0hEBVGIRQCEiZoHQwtlGSByCCdYBl8g8egTTAWoKQMRBRBcZxYlhzhKegqMOageErsCHVkk3hXIFooDgHB1KkHIHVgzKB4ADJQ/A1jAFmAYhkQqA5TOBtocrKrgXwQA8gcFIuAIO8sQSA7hidvPwaQGZSaAYHOUWJABhWWw2EMIH9QagQERU4SArJXo0ZZL18uvaxejXt/Em8xjVBXmvFr1KVm/AJ10tRe2XnraNqaJvKE3KHuUbfK1E+VHB0q40/y3sdQSxY4FHWeKJCunP8UyDdqJZenT3ntVV5jIYCAh20vT7ioP8tpf6E2lfEMwERe+whV1MHjwZB7PBiCxcGQWwKZKD62lfGNnP/1poFAA60T7rF1UgcKd2id3KDeUS+oLWV8DfWAepOfq00CgQabi9zjcgJVYVD7PVzQUAUGAQkbNJTBICDhgwYTjDYD6XeW08ZKh+A4pYkzenOxXUbvZcWz7E8ykRMnIHGX1XPl+1m2vPYpL+2qdb8CDAARlKFEz/ZVkAAAAABJRU5ErkJggg==); +} + +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_calendar td, +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_calendar th { + background: #0a0a0a; + border: 1px solid #222; + color: #999; +} + +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_calendar th { + background: #0e0e0e; +} + +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_calendar td.xdsoft_today { + color: #cc5500; +} + +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_calendar td.xdsoft_highlighted_default { + background: #ffe9d2; + box-shadow: #ffb871 0 1px 4px 0 inset; + color:#000; +} +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_calendar td.xdsoft_highlighted_mint { + background: #c1ffc9; + box-shadow: #00dd1c 0 1px 4px 0 inset; + color:#000; +} + +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_calendar td.xdsoft_default, +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_calendar td.xdsoft_current, +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_timepicker .xdsoft_time_box >div >div.xdsoft_current { + background: #cc5500; + box-shadow: #b03e00 0 1px 3px 0 inset; + color: #000; +} + +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_calendar td:hover, +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_timepicker .xdsoft_time_box >div >div:hover { + color: #000 !important; + background: #007fff !important; +} + +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_calendar th { + color: #666; +} + +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_copyright { color: #333 !important } +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_copyright a { color: #111 !important } +.xdsoft_datetimepicker.xdsoft_dark .xdsoft_copyright a:hover { color: #555 !important } + +.xdsoft_dark .xdsoft_time_box { + border: 1px solid #333; +} + +.xdsoft_dark .xdsoft_scrollbar >.xdsoft_scroller { + background: #333 !important; +} +.xdsoft_datetimepicker .xdsoft_save_selected { + display: block; + border: 1px solid #dddddd !important; + margin-top: 5px; + width: 100%; + color: #454551; + font-size: 13px; +} +.xdsoft_datetimepicker .blue-gradient-button { + font-family: "museo-sans", "Book Antiqua", sans-serif; + font-size: 12px; + font-weight: 300; + color: #82878c; + height: 28px; + position: relative; + padding: 4px 17px 4px 33px; + border: 1px solid #d7d8da; + background: -moz-linear-gradient(top, #fff 0%, #f4f8fa 73%); + /* FF3.6+ */ + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #fff), color-stop(73%, #f4f8fa)); + /* Chrome,Safari4+ */ + background: -webkit-linear-gradient(top, #fff 0%, #f4f8fa 73%); + /* Chrome10+,Safari5.1+ */ + background: -o-linear-gradient(top, #fff 0%, #f4f8fa 73%); + /* Opera 11.10+ */ + background: -ms-linear-gradient(top, #fff 0%, #f4f8fa 73%); + /* IE10+ */ + background: linear-gradient(to bottom, #fff 0%, #f4f8fa 73%); + /* W3C */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fff', endColorstr='#f4f8fa',GradientType=0 ); +/* IE6-9 */ +} +.xdsoft_datetimepicker .blue-gradient-button:hover, .xdsoft_datetimepicker .blue-gradient-button:focus, .xdsoft_datetimepicker .blue-gradient-button:hover span, .xdsoft_datetimepicker .blue-gradient-button:focus span { + color: #454551; + background: -moz-linear-gradient(top, #f4f8fa 0%, #FFF 73%); + /* FF3.6+ */ + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #f4f8fa), color-stop(73%, #FFF)); + /* Chrome,Safari4+ */ + background: -webkit-linear-gradient(top, #f4f8fa 0%, #FFF 73%); + /* Chrome10+,Safari5.1+ */ + background: -o-linear-gradient(top, #f4f8fa 0%, #FFF 73%); + /* Opera 11.10+ */ + background: -ms-linear-gradient(top, #f4f8fa 0%, #FFF 73%); + /* IE10+ */ + background: linear-gradient(to bottom, #f4f8fa 0%, #FFF 73%); + /* W3C */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f4f8fa', endColorstr='#FFF',GradientType=0 ); + /* IE6-9 */ +} +/* FINISH jquery.datetimepicker.full.min.js */ \ No newline at end of file diff --git a/app/app/templates/components/section/github/type-editor.hbs b/app/app/templates/components/section/github/type-editor.hbs index d38ca717..c0f5c770 100644 --- a/app/app/templates/components/section/github/type-editor.hbs +++ b/app/app/templates/components/section/github/type-editor.hbs @@ -34,8 +34,10 @@
Select report type
{{ui-select id="report-dropdown" content=reports action=(action 'onReportChange') optionValuePath="id" optionLabelPath="name" selection=config.report}} + Show items since {{input id="branch-since" value=config.branchSince type="text" }}
+ Number of items to show {{input id="branch-lines" value=config.branchLines type="number" min="1" step="1" max="100" }}
{{#if showIssueNum}} - {{input id="issue-number" value=config.issueNum type="number" min="1" step="1" enter='onIssueNumChange'}} + Issue Number: {{input id="issue-number" value=config.issueNum type="number" min="1" step="1" }} {{/if}} {{#if showCommits}}
@@ -56,6 +58,25 @@
{{/if}} + {{#if showLabels}} +
+ +
Select labels - an issue must have all labels to be shown, if no label is selected all issues are shown.
+
+ {{#each config.lists as |list|}} +
+ {{#if list.included}} + check_box + {{else}} + check_box_outline_blank + {{/if}} + {{list.name}} +
+ {{/each}} +
+
+
+ {{/if}} {{/if}}
diff --git a/app/config/environment.js b/app/config/environment.js index 661b1329..dd786758 100644 --- a/app/config/environment.js +++ b/app/config/environment.js @@ -12,6 +12,7 @@ /* jshint node: true */ module.exports = function(environment) { + var ENV = { modulePrefix: 'documize', podModulePrefix: 'documize/pods', @@ -25,13 +26,13 @@ module.exports = function(environment) { EmberENV: { FEATURES: {} }, - "ember-cli-mirage": { + "ember-cli-mirage": { enabled: false }, APP: { // Allows to disable audit service in tests auditEnabled: true, - intercomKey: "" + intercomKey: "" } }; @@ -39,7 +40,7 @@ module.exports = function(environment) { ENV.APP.LOG_TRANSITIONS = true; ENV.APP.LOG_TRANSITIONS_INTERNAL = true; ENV['ember-cli-mirage'] = { - enabled: false + enabled: false }; ENV.apiHost = "https://localhost:5001"; @@ -56,7 +57,7 @@ module.exports = function(environment) { ENV.locationType = 'none'; ENV.APP.rootElement = '#ember-testing'; ENV['ember-cli-mirage'] = { - enabled: true + enabled: true }; ENV.APP.auditEnabled = false; @@ -73,21 +74,21 @@ module.exports = function(environment) { ENV.apiHost = ""; } - process.argv.forEach(function(element) { - if (element !== undefined) { - if (element.startsWith("intercom=")) { - element = element.replace("intercom=", ""); - ENV.APP.intercomKey = element; - } - if (element.startsWith("apiHost=")) { - element = element.replace("apiHost=", ""); - ENV.apiHost = element; - } - } - }); + process.argv.forEach(function(element) { + if (element !== undefined) { + if (element.startsWith("intercom=")) { + element = element.replace("intercom=", ""); + ENV.APP.intercomKey = element; + } + if (element.startsWith("apiHost=")) { + element = element.replace("apiHost=", ""); + ENV.apiHost = element; + } + } + }); ENV.apiNamespace = "api"; ENV.contentSecurityPolicy = null; return ENV; -}; +}; \ No newline at end of file diff --git a/app/ember-cli-build.js b/app/ember-cli-build.js index 7f2cfe05..9503e45a 100644 --- a/app/ember-cli-build.js +++ b/app/ember-cli-build.js @@ -52,8 +52,9 @@ module.exports = function(defaults) { app.import('vendor/tether.js'); app.import('vendor/drop.js'); app.import('vendor/tooltip.js'); - app.import('vendor/markdown-it.min.js'); - app.import('vendor/dragula.js'); + app.import('vendor/markdown-it.min.js'); + app.import('vendor/dragula.js'); + app.import('vendor/datetimepicker.min.js'); return app.toTree(); -}; +}; \ No newline at end of file diff --git a/app/vendor/datetimepicker.min.js b/app/vendor/datetimepicker.min.js new file mode 100644 index 00000000..e957cedb --- /dev/null +++ b/app/vendor/datetimepicker.min.js @@ -0,0 +1,2 @@ +var DateFormatter;!function(){"use strict";var e,t,a,r,n,o;n=864e5,o=3600,e=function(e,t){return"string"==typeof e&&"string"==typeof t&&e.toLowerCase()===t.toLowerCase()},t=function(e,a,r){var n=r||"0",o=e.toString();return o.lengths?"20":"19")+i):4===f&&(y.year=s),h=!0;break;case"m":case"n":case"M":case"F":isNaN(i)?(d=p.monthsShort.indexOf(i),d>-1&&(y.month=d+1),d=p.months.indexOf(i),d>-1&&(y.month=d+1)):s>=1&&12>=s&&(y.month=s),h=!0;break;case"d":case"j":s>=1&&31>=s&&(y.day=s),h=!0;break;case"g":case"h":u=r.indexOf("a")>-1?r.indexOf("a"):r.indexOf("A")>-1?r.indexOf("A"):-1,c=n[u],u>-1?(l=e(c,p.meridiem[0])?0:e(c,p.meridiem[1])?12:-1,s>=1&&12>=s&&l>-1?y.hour=s+l:s>=0&&23>=s&&(y.hour=s)):s>=0&&23>=s&&(y.hour=s),g=!0;break;case"G":case"H":s>=0&&23>=s&&(y.hour=s),g=!0;break;case"i":s>=0&&59>=s&&(y.min=s),g=!0;break;case"s":s>=0&&59>=s&&(y.sec=s),g=!0}if(h===!0&&y.year&&y.month&&y.day)y.date=new Date(y.year,y.month-1,y.day,y.hour,y.min,y.sec,0);else{if(g!==!0)return!1;y.date=new Date(0,0,0,y.hour,y.min,y.sec,0)}return y.date},guessDate:function(e,t){if("string"!=typeof e)return e;var a,r,n,o,i=this,s=e.replace(i.separators,"\x00").split("\x00"),d=/^[djmn]/g,u=t.match(i.validParts),l=new Date,f=0;if(!d.test(u[0]))return e;for(r=0;r0&&s.splice(r+1,0,n.substr(f))}return l},parseFormat:function(e,a){var r,i=this,s=i.dateSettings,d=/\\?(.?)/gi,u=function(e,t){return r[e]?r[e]():t};return r={d:function(){return t(r.j(),2)},D:function(){return s.daysShort[r.w()]},j:function(){return a.getDate()},l:function(){return s.days[r.w()]},N:function(){return r.w()||7},w:function(){return a.getDay()},z:function(){var e=new Date(r.Y(),r.n()-1,r.j()),t=new Date(r.Y(),0,1);return Math.round((e-t)/n)},W:function(){var e=new Date(r.Y(),r.n()-1,r.j()-r.N()+3),a=new Date(e.getFullYear(),0,4);return t(1+Math.round((e-a)/n/7),2)},F:function(){return s.months[a.getMonth()]},m:function(){return t(r.n(),2)},M:function(){return s.monthsShort[a.getMonth()]},n:function(){return a.getMonth()+1},t:function(){return new Date(r.Y(),r.n(),0).getDate()},L:function(){var e=r.Y();return e%4===0&&e%100!==0||e%400===0?1:0},o:function(){var e=r.n(),t=r.W(),a=r.Y();return a+(12===e&&9>t?1:1===e&&t>9?-1:0)},Y:function(){return a.getFullYear()},y:function(){return r.Y().toString().slice(-2)},a:function(){return r.A().toLowerCase()},A:function(){var e=r.G()<12?0:1;return s.meridiem[e]},B:function(){var e=a.getUTCHours()*o,r=60*a.getUTCMinutes(),n=a.getUTCSeconds();return t(Math.floor((e+r+n+o)/86.4)%1e3,3)},g:function(){return r.G()%12||12},G:function(){return a.getHours()},h:function(){return t(r.g(),2)},H:function(){return t(r.G(),2)},i:function(){return t(a.getMinutes(),2)},s:function(){return t(a.getSeconds(),2)},u:function(){return t(1e3*a.getMilliseconds(),6)},e:function(){var e=/\((.*)\)/.exec(String(a))[1];return e||"Coordinated Universal Time"},T:function(){var e=(String(a).match(i.tzParts)||[""]).pop().replace(i.tzClip,"");return e||"UTC"},I:function(){var e=new Date(r.Y(),0),t=Date.UTC(r.Y(),0),a=new Date(r.Y(),6),n=Date.UTC(r.Y(),6);return e-t!==a-n?1:0},O:function(){var e=a.getTimezoneOffset(),r=Math.abs(e);return(e>0?"-":"+")+t(100*Math.floor(r/60)+r%60,4)},P:function(){var e=r.O();return e.substr(0,3)+":"+e.substr(3,2)},Z:function(){return 60*-a.getTimezoneOffset()},c:function(){return"Y-m-d\\TH:i:sP".replace(d,u)},r:function(){return"D, d M Y H:i:s O".replace(d,u)},U:function(){return a.getTime()/1e3||0}},u(e,e)},formatDate:function(e,t){var a,r,n,o,i,s=this,d="";if("string"==typeof e&&(e=s.parseDate(e,t),e===!1))return!1;if(e instanceof Date){for(n=t.length,a=0;n>a;a++)i=t.charAt(a),"S"!==i&&(o=s.parseFormat(i,e),a!==n-1&&s.intParts.test(i)&&"S"===t.charAt(a+1)&&(r=parseInt(o),o+=s.dateSettings.ordinal(r)),d+=o);return d}return""}}}(),function(e){"function"==typeof define&&define.amd?define(["jquery","jquery-mousewheel"],e):"object"==typeof exports?module.exports=e:e(jQuery)}(function(e){"use strict";function t(e,t,a){this.date=e,this.desc=t,this.style=a}var a={i18n:{ar:{months:["كانون الثاني","شباط","آذار","نيسان","مايو","حزيران","تموز","آب","أيلول","تشرين الأول","تشرين الثاني","كانون الأول"],dayOfWeekShort:["ن","ث","ع","خ","ج","س","ح"],dayOfWeek:["الأحد","الاثنين","الثلاثاء","الأربعاء","الخميس","الجمعة","السبت","الأحد"]},ro:{months:["Ianuarie","Februarie","Martie","Aprilie","Mai","Iunie","Iulie","August","Septembrie","Octombrie","Noiembrie","Decembrie"],dayOfWeekShort:["Du","Lu","Ma","Mi","Jo","Vi","Sâ"],dayOfWeek:["Duminică","Luni","Marţi","Miercuri","Joi","Vineri","Sâmbătă"]},id:{months:["Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember"],dayOfWeekShort:["Min","Sen","Sel","Rab","Kam","Jum","Sab"],dayOfWeek:["Minggu","Senin","Selasa","Rabu","Kamis","Jumat","Sabtu"]},is:{months:["Janúar","Febrúar","Mars","Apríl","Maí","Júní","Júlí","Ágúst","September","Október","Nóvember","Desember"],dayOfWeekShort:["Sun","Mán","Þrið","Mið","Fim","Fös","Lau"],dayOfWeek:["Sunnudagur","Mánudagur","Þriðjudagur","Miðvikudagur","Fimmtudagur","Föstudagur","Laugardagur"]},bg:{months:["Януари","Февруари","Март","Април","Май","Юни","Юли","Август","Септември","Октомври","Ноември","Декември"],dayOfWeekShort:["Нд","Пн","Вт","Ср","Чт","Пт","Сб"],dayOfWeek:["Неделя","Понеделник","Вторник","Сряда","Четвъртък","Петък","Събота"]},fa:{months:["فروردین","اردیبهشت","خرداد","تیر","مرداد","شهریور","مهر","آبان","آذر","دی","بهمن","اسفند"],dayOfWeekShort:["یکشنبه","دوشنبه","سه شنبه","چهارشنبه","پنجشنبه","جمعه","شنبه"],dayOfWeek:["یک‌شنبه","دوشنبه","سه‌شنبه","چهارشنبه","پنج‌شنبه","جمعه","شنبه","یک‌شنبه"]},ru:{months:["Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"],dayOfWeekShort:["Вс","Пн","Вт","Ср","Чт","Пт","Сб"],dayOfWeek:["Воскресенье","Понедельник","Вторник","Среда","Четверг","Пятница","Суббота"]},uk:{months:["Січень","Лютий","Березень","Квітень","Травень","Червень","Липень","Серпень","Вересень","Жовтень","Листопад","Грудень"],dayOfWeekShort:["Ндл","Пнд","Втр","Срд","Чтв","Птн","Сбт"],dayOfWeek:["Неділя","Понеділок","Вівторок","Середа","Четвер","П'ятниця","Субота"]},en:{months:["January","February","March","April","May","June","July","August","September","October","November","December"],dayOfWeekShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayOfWeek:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},el:{months:["Ιανουάριος","Φεβρουάριος","Μάρτιος","Απρίλιος","Μάιος","Ιούνιος","Ιούλιος","Αύγουστος","Σεπτέμβριος","Οκτώβριος","Νοέμβριος","Δεκέμβριος"],dayOfWeekShort:["Κυρ","Δευ","Τρι","Τετ","Πεμ","Παρ","Σαβ"],dayOfWeek:["Κυριακή","Δευτέρα","Τρίτη","Τετάρτη","Πέμπτη","Παρασκευή","Σάββατο"]},de:{months:["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],dayOfWeekShort:["So","Mo","Di","Mi","Do","Fr","Sa"],dayOfWeek:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"]},nl:{months:["januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december"],dayOfWeekShort:["zo","ma","di","wo","do","vr","za"],dayOfWeek:["zondag","maandag","dinsdag","woensdag","donderdag","vrijdag","zaterdag"]},tr:{months:["Ocak","Şubat","Mart","Nisan","Mayıs","Haziran","Temmuz","Ağustos","Eylül","Ekim","Kasım","Aralık"],dayOfWeekShort:["Paz","Pts","Sal","Çar","Per","Cum","Cts"],dayOfWeek:["Pazar","Pazartesi","Salı","Çarşamba","Perşembe","Cuma","Cumartesi"]},fr:{months:["Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre"],dayOfWeekShort:["Dim","Lun","Mar","Mer","Jeu","Ven","Sam"],dayOfWeek:["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"]},es:{months:["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],dayOfWeekShort:["Dom","Lun","Mar","Mié","Jue","Vie","Sáb"],dayOfWeek:["Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado"]},th:{months:["มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม"],dayOfWeekShort:["อา.","จ.","อ.","พ.","พฤ.","ศ.","ส."],dayOfWeek:["อาทิตย์","จันทร์","อังคาร","พุธ","พฤหัส","ศุกร์","เสาร์","อาทิตย์"]},pl:{months:["styczeń","luty","marzec","kwiecień","maj","czerwiec","lipiec","sierpień","wrzesień","październik","listopad","grudzień"],dayOfWeekShort:["nd","pn","wt","śr","cz","pt","sb"],dayOfWeek:["niedziela","poniedziałek","wtorek","środa","czwartek","piątek","sobota"]},pt:{months:["Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"],dayOfWeekShort:["Dom","Seg","Ter","Qua","Qui","Sex","Sab"],dayOfWeek:["Domingo","Segunda","Terça","Quarta","Quinta","Sexta","Sábado"]},ch:{months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],dayOfWeekShort:["日","一","二","三","四","五","六"]},se:{months:["Januari","Februari","Mars","April","Maj","Juni","Juli","Augusti","September","Oktober","November","December"],dayOfWeekShort:["Sön","Mån","Tis","Ons","Tor","Fre","Lör"]},kr:{months:["1월","2월","3월","4월","5월","6월","7월","8월","9월","10월","11월","12월"],dayOfWeekShort:["일","월","화","수","목","금","토"],dayOfWeek:["일요일","월요일","화요일","수요일","목요일","금요일","토요일"]},it:{months:["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"],dayOfWeekShort:["Dom","Lun","Mar","Mer","Gio","Ven","Sab"],dayOfWeek:["Domenica","Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"]},da:{months:["January","Februar","Marts","April","Maj","Juni","July","August","September","Oktober","November","December"],dayOfWeekShort:["Søn","Man","Tir","Ons","Tor","Fre","Lør"],dayOfWeek:["søndag","mandag","tirsdag","onsdag","torsdag","fredag","lørdag"]},no:{months:["Januar","Februar","Mars","April","Mai","Juni","Juli","August","September","Oktober","November","Desember"],dayOfWeekShort:["Søn","Man","Tir","Ons","Tor","Fre","Lør"],dayOfWeek:["Søndag","Mandag","Tirsdag","Onsdag","Torsdag","Fredag","Lørdag"]},ja:{months:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],dayOfWeekShort:["日","月","火","水","木","金","土"],dayOfWeek:["日曜","月曜","火曜","水曜","木曜","金曜","土曜"]},vi:{months:["Tháng 1","Tháng 2","Tháng 3","Tháng 4","Tháng 5","Tháng 6","Tháng 7","Tháng 8","Tháng 9","Tháng 10","Tháng 11","Tháng 12"],dayOfWeekShort:["CN","T2","T3","T4","T5","T6","T7"],dayOfWeek:["Chủ nhật","Thứ hai","Thứ ba","Thứ tư","Thứ năm","Thứ sáu","Thứ bảy"]},sl:{months:["Januar","Februar","Marec","April","Maj","Junij","Julij","Avgust","September","Oktober","November","December"],dayOfWeekShort:["Ned","Pon","Tor","Sre","Čet","Pet","Sob"],dayOfWeek:["Nedelja","Ponedeljek","Torek","Sreda","Četrtek","Petek","Sobota"]},cs:{months:["Leden","Únor","Březen","Duben","Květen","Červen","Červenec","Srpen","Září","Říjen","Listopad","Prosinec"],dayOfWeekShort:["Ne","Po","Út","St","Čt","Pá","So"]},hu:{months:["Január","Február","Március","Április","Május","Június","Július","Augusztus","Szeptember","Október","November","December"],dayOfWeekShort:["Va","Hé","Ke","Sze","Cs","Pé","Szo"],dayOfWeek:["vasárnap","hétfő","kedd","szerda","csütörtök","péntek","szombat"]},az:{months:["Yanvar","Fevral","Mart","Aprel","May","Iyun","Iyul","Avqust","Sentyabr","Oktyabr","Noyabr","Dekabr"],dayOfWeekShort:["B","Be","Ça","Ç","Ca","C","Ş"],dayOfWeek:["Bazar","Bazar ertəsi","Çərşənbə axşamı","Çərşənbə","Cümə axşamı","Cümə","Şənbə"]},bs:{months:["Januar","Februar","Mart","April","Maj","Jun","Jul","Avgust","Septembar","Oktobar","Novembar","Decembar"],dayOfWeekShort:["Ned","Pon","Uto","Sri","Čet","Pet","Sub"],dayOfWeek:["Nedjelja","Ponedjeljak","Utorak","Srijeda","Četvrtak","Petak","Subota"]},ca:{months:["Gener","Febrer","Març","Abril","Maig","Juny","Juliol","Agost","Setembre","Octubre","Novembre","Desembre"],dayOfWeekShort:["Dg","Dl","Dt","Dc","Dj","Dv","Ds"],dayOfWeek:["Diumenge","Dilluns","Dimarts","Dimecres","Dijous","Divendres","Dissabte"]},"en-GB":{months:["January","February","March","April","May","June","July","August","September","October","November","December"],dayOfWeekShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayOfWeek:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},et:{months:["Jaanuar","Veebruar","Märts","Aprill","Mai","Juuni","Juuli","August","September","Oktoober","November","Detsember"],dayOfWeekShort:["P","E","T","K","N","R","L"],dayOfWeek:["Pühapäev","Esmaspäev","Teisipäev","Kolmapäev","Neljapäev","Reede","Laupäev"]},eu:{months:["Urtarrila","Otsaila","Martxoa","Apirila","Maiatza","Ekaina","Uztaila","Abuztua","Iraila","Urria","Azaroa","Abendua"],dayOfWeekShort:["Ig.","Al.","Ar.","Az.","Og.","Or.","La."],dayOfWeek:["Igandea","Astelehena","Asteartea","Asteazkena","Osteguna","Ostirala","Larunbata"]},fi:{months:["Tammikuu","Helmikuu","Maaliskuu","Huhtikuu","Toukokuu","Kesäkuu","Heinäkuu","Elokuu","Syyskuu","Lokakuu","Marraskuu","Joulukuu"],dayOfWeekShort:["Su","Ma","Ti","Ke","To","Pe","La"],dayOfWeek:["sunnuntai","maanantai","tiistai","keskiviikko","torstai","perjantai","lauantai"]},gl:{months:["Xan","Feb","Maz","Abr","Mai","Xun","Xul","Ago","Set","Out","Nov","Dec"],dayOfWeekShort:["Dom","Lun","Mar","Mer","Xov","Ven","Sab"],dayOfWeek:["Domingo","Luns","Martes","Mércores","Xoves","Venres","Sábado"]},hr:{months:["Siječanj","Veljača","Ožujak","Travanj","Svibanj","Lipanj","Srpanj","Kolovoz","Rujan","Listopad","Studeni","Prosinac"],dayOfWeekShort:["Ned","Pon","Uto","Sri","Čet","Pet","Sub"],dayOfWeek:["Nedjelja","Ponedjeljak","Utorak","Srijeda","Četvrtak","Petak","Subota"]},ko:{months:["1월","2월","3월","4월","5월","6월","7월","8월","9월","10월","11월","12월"],dayOfWeekShort:["일","월","화","수","목","금","토"],dayOfWeek:["일요일","월요일","화요일","수요일","목요일","금요일","토요일"]},lt:{months:["Sausio","Vasario","Kovo","Balandžio","Gegužės","Birželio","Liepos","Rugpjūčio","Rugsėjo","Spalio","Lapkričio","Gruodžio"],dayOfWeekShort:["Sek","Pir","Ant","Tre","Ket","Pen","Šeš"],dayOfWeek:["Sekmadienis","Pirmadienis","Antradienis","Trečiadienis","Ketvirtadienis","Penktadienis","Šeštadienis"]},lv:{months:["Janvāris","Februāris","Marts","Aprīlis ","Maijs","Jūnijs","Jūlijs","Augusts","Septembris","Oktobris","Novembris","Decembris"],dayOfWeekShort:["Sv","Pr","Ot","Tr","Ct","Pk","St"],dayOfWeek:["Svētdiena","Pirmdiena","Otrdiena","Trešdiena","Ceturtdiena","Piektdiena","Sestdiena"]},mk:{months:["јануари","февруари","март","април","мај","јуни","јули","август","септември","октомври","ноември","декември"],dayOfWeekShort:["нед","пон","вто","сре","чет","пет","саб"],dayOfWeek:["Недела","Понеделник","Вторник","Среда","Четврток","Петок","Сабота"]},mn:{months:["1-р сар","2-р сар","3-р сар","4-р сар","5-р сар","6-р сар","7-р сар","8-р сар","9-р сар","10-р сар","11-р сар","12-р сар"],dayOfWeekShort:["Дав","Мяг","Лха","Пүр","Бсн","Бям","Ням"],dayOfWeek:["Даваа","Мягмар","Лхагва","Пүрэв","Баасан","Бямба","Ням"]},"pt-BR":{months:["Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"],dayOfWeekShort:["Dom","Seg","Ter","Qua","Qui","Sex","Sáb"],dayOfWeek:["Domingo","Segunda","Terça","Quarta","Quinta","Sexta","Sábado"]},sk:{months:["Január","Február","Marec","Apríl","Máj","Jún","Júl","August","September","Október","November","December"],dayOfWeekShort:["Ne","Po","Ut","St","Št","Pi","So"],dayOfWeek:["Nedeľa","Pondelok","Utorok","Streda","Štvrtok","Piatok","Sobota"]},sq:{months:["Janar","Shkurt","Mars","Prill","Maj","Qershor","Korrik","Gusht","Shtator","Tetor","Nëntor","Dhjetor"],dayOfWeekShort:["Die","Hën","Mar","Mër","Enj","Pre","Shtu"],dayOfWeek:["E Diel","E Hënë","E Martē","E Mërkurë","E Enjte","E Premte","E Shtunë"]},"sr-YU":{months:["Januar","Februar","Mart","April","Maj","Jun","Jul","Avgust","Septembar","Oktobar","Novembar","Decembar"],dayOfWeekShort:["Ned","Pon","Uto","Sre","čet","Pet","Sub"],dayOfWeek:["Nedelja","Ponedeljak","Utorak","Sreda","Četvrtak","Petak","Subota"]},sr:{months:["јануар","фебруар","март","април","мај","јун","јул","август","септембар","октобар","новембар","децембар"],dayOfWeekShort:["нед","пон","уто","сре","чет","пет","суб"],dayOfWeek:["Недеља","Понедељак","Уторак","Среда","Четвртак","Петак","Субота"]},sv:{months:["Januari","Februari","Mars","April","Maj","Juni","Juli","Augusti","September","Oktober","November","December"],dayOfWeekShort:["Sön","Mån","Tis","Ons","Tor","Fre","Lör"],dayOfWeek:["Söndag","Måndag","Tisdag","Onsdag","Torsdag","Fredag","Lördag"]},"zh-TW":{months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],dayOfWeekShort:["日","一","二","三","四","五","六"],dayOfWeek:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},zh:{months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],dayOfWeekShort:["日","一","二","三","四","五","六"],dayOfWeek:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]},he:{months:["ינואר","פברואר","מרץ","אפריל","מאי","יוני","יולי","אוגוסט","ספטמבר","אוקטובר","נובמבר","דצמבר"],dayOfWeekShort:["א'","ב'","ג'","ד'","ה'","ו'","שבת"],dayOfWeek:["ראשון","שני","שלישי","רביעי","חמישי","שישי","שבת","ראשון"]},hy:{months:["Հունվար","Փետրվար","Մարտ","Ապրիլ","Մայիս","Հունիս","Հուլիս","Օգոստոս","Սեպտեմբեր","Հոկտեմբեր","Նոյեմբեր","Դեկտեմբեր"],dayOfWeekShort:["Կի","Երկ","Երք","Չոր","Հնգ","Ուրբ","Շբթ"],dayOfWeek:["Կիրակի","Երկուշաբթի","Երեքշաբթի","Չորեքշաբթի","Հինգշաբթի","Ուրբաթ","Շաբաթ"]},kg:{months:["Үчтүн айы","Бирдин айы","Жалган Куран","Чын Куран","Бугу","Кулжа","Теке","Баш Оона","Аяк Оона","Тогуздун айы","Жетинин айы","Бештин айы"],dayOfWeekShort:["Жек","Дүй","Шей","Шар","Бей","Жум","Ише"],dayOfWeek:["Жекшемб","Дүйшөмб","Шейшемб","Шаршемб","Бейшемби","Жума","Ишенб"]},rm:{months:["Schaner","Favrer","Mars","Avrigl","Matg","Zercladur","Fanadur","Avust","Settember","October","November","December"],dayOfWeekShort:["Du","Gli","Ma","Me","Gie","Ve","So"],dayOfWeek:["Dumengia","Glindesdi","Mardi","Mesemna","Gievgia","Venderdi","Sonda"]},ka:{months:["იანვარი","თებერვალი","მარტი","აპრილი","მაისი","ივნისი","ივლისი","აგვისტო","სექტემბერი","ოქტომბერი","ნოემბერი","დეკემბერი"],dayOfWeekShort:["კვ","ორშ","სამშ","ოთხ","ხუთ","პარ","შაბ"],dayOfWeek:["კვირა","ორშაბათი","სამშაბათი","ოთხშაბათი","ხუთშაბათი","პარასკევი","შაბათი"]}},value:"",rtl:!1,format:"Y/m/d H:i",formatTime:"H:i",formatDate:"Y/m/d",startDate:!1,step:60,monthChangeSpinner:!0,closeOnDateSelect:!1,closeOnTimeSelect:!0,closeOnWithoutClick:!0,closeOnInputClick:!0,timepicker:!0,datepicker:!0,weeks:!1,defaultTime:!1,defaultDate:!1,minDate:!1,maxDate:!1,minTime:!1,maxTime:!1,disabledMinTime:!1,disabledMaxTime:!1,allowTimes:[],opened:!1,initTime:!0,inline:!1,theme:"",onSelectDate:function(){},onSelectTime:function(){},onChangeMonth:function(){},onGetWeekOfYear:function(){},onChangeYear:function(){},onChangeDateTime:function(){},onShow:function(){},onClose:function(){},onGenerate:function(){},withoutCopyright:!0,inverseButton:!1,hours12:!1,next:"xdsoft_next",prev:"xdsoft_prev",dayOfWeekStart:0,parentID:"body",timeHeightInTimePicker:25,timepickerScrollbar:!0,todayButton:!0,prevButton:!0,nextButton:!0,defaultSelect:!0,scrollMonth:!0,scrollTime:!0,scrollInput:!0,lazyInit:!1,mask:!1,validateOnBlur:!0,allowBlank:!0,yearStart:1950,yearEnd:2050,monthStart:0,monthEnd:11,style:"",id:"",fixed:!1,roundTime:"round",className:"",weekends:[],highlightedDates:[],highlightedPeriods:[],allowDates:[],allowDateRe:null,disabledDates:[],disabledWeekDays:[],yearOffset:0,beforeShowDay:null,enterLikeTab:!0,showApplyButton:!1},r=null,n="en",o="en",i={meridiem:["AM","PM"]},s=function(){var t=a.i18n[o],n={days:t.dayOfWeek,daysShort:t.dayOfWeekShort,months:t.months,monthsShort:e.map(t.months,function(e){return e.substring(0,3)})};r=new DateFormatter({dateSettings:e.extend({},i,n)})};e.datetimepicker={setLocale:function(e){var t=a.i18n[e]?e:n;o!=t&&(o=t,s())},setDateFormatter:function(e){r=e},RFC_2822:"D, d M Y H:i:s O",ATOM:"Y-m-dTH:i:sP",ISO_8601:"Y-m-dTH:i:sO",RFC_822:"D, d M y H:i:s O",RFC_850:"l, d-M-y H:i:s T",RFC_1036:"D, d M y H:i:s O",RFC_1123:"D, d M Y H:i:s O",RSS:"D, d M Y H:i:s O",W3C:"Y-m-dTH:i:sP"},s(),window.getComputedStyle||(window.getComputedStyle=function(e){return this.el=e,this.getPropertyValue=function(t){var a=/(\-([a-z]){1})/g;return"float"===t&&(t="styleFloat"),a.test(t)&&(t=t.replace(a,function(e,t,a){return a.toUpperCase()})),e.currentStyle[t]||null},this}),Array.prototype.indexOf||(Array.prototype.indexOf=function(e,t){var a,r;for(a=t||0,r=this.length;r>a;a+=1)if(this[a]===e)return a;return-1}),Date.prototype.countDaysInMonth=function(){return new Date(this.getFullYear(),this.getMonth()+1,0).getDate()},e.fn.xdsoftScroller=function(t){return this.each(function(){var a,r,n,o,i,s=e(this),d=function(e){var t,a={x:0,y:0};return"touchstart"===e.type||"touchmove"===e.type||"touchend"===e.type||"touchcancel"===e.type?(t=e.originalEvent.touches[0]||e.originalEvent.changedTouches[0],a.x=t.clientX,a.y=t.clientY):("mousedown"===e.type||"mouseup"===e.type||"mousemove"===e.type||"mouseover"===e.type||"mouseout"===e.type||"mouseenter"===e.type||"mouseleave"===e.type)&&(a.x=e.clientX,a.y=e.clientY),a},u=100,l=!1,f=0,c=0,m=0,h=!1,g=0,p=function(){};return"hide"===t?void s.find(".xdsoft_scrollbar").hide():(e(this).hasClass("xdsoft_scroller_box")||(a=s.children().eq(0),r=s[0].clientHeight,n=a[0].offsetHeight,o=e('
'),i=e('
'),o.append(i),s.addClass("xdsoft_scroller_box").append(o),p=function(e){var t=d(e).y-f+g;0>t&&(t=0),t+i[0].offsetHeight>m&&(t=m-i[0].offsetHeight),s.trigger("scroll_element.xdsoft_scroller",[u?t/u:0])},i.on("touchstart.xdsoft_scroller mousedown.xdsoft_scroller",function(a){r||s.trigger("resize_scroll.xdsoft_scroller",[t]),f=d(a).y,g=parseInt(i.css("margin-top"),10),m=o[0].offsetHeight,"mousedown"===a.type||"touchstart"===a.type?(document&&e(document.body).addClass("xdsoft_noselect"),e([document.body,window]).on("touchend mouseup.xdsoft_scroller",function n(){e([document.body,window]).off("touchend mouseup.xdsoft_scroller",n).off("mousemove.xdsoft_scroller",p).removeClass("xdsoft_noselect")}),e(document.body).on("mousemove.xdsoft_scroller",p)):(h=!0,a.stopPropagation(),a.preventDefault())}).on("touchmove",function(e){h&&(e.preventDefault(),p(e))}).on("touchend touchcancel",function(){h=!1,g=0}),s.on("scroll_element.xdsoft_scroller",function(e,t){r||s.trigger("resize_scroll.xdsoft_scroller",[t,!0]),t=t>1?1:0>t||isNaN(t)?0:t,i.css("margin-top",u*t),setTimeout(function(){a.css("marginTop",-parseInt((a[0].offsetHeight-r)*t,10))},10)}).on("resize_scroll.xdsoft_scroller",function(e,t,d){var l,f;r=s[0].clientHeight,n=a[0].offsetHeight,l=r/n,f=l*o[0].offsetHeight,l>1?i.hide():(i.show(),i.css("height",parseInt(f>10?f:10,10)),u=o[0].offsetHeight-i[0].offsetHeight,d!==!0&&s.trigger("scroll_element.xdsoft_scroller",[t||Math.abs(parseInt(a.css("marginTop"),10))/(n-r)]))}),s.on("mousewheel",function(e){var t=Math.abs(parseInt(a.css("marginTop"),10));return t-=20*e.deltaY,0>t&&(t=0),s.trigger("scroll_element.xdsoft_scroller",[t/(n-r)]),e.stopPropagation(),!1}),s.on("touchstart",function(e){l=d(e),c=Math.abs(parseInt(a.css("marginTop"),10))}),s.on("touchmove",function(e){if(l){e.preventDefault();var t=d(e);s.trigger("scroll_element.xdsoft_scroller",[(c-(t.y-l.y))/(n-r)])}}),s.on("touchend touchcancel",function(){l=!1,c=0})),void s.trigger("resize_scroll.xdsoft_scroller",[t]))})},e.fn.datetimepicker=function(n,i){var s,d,u=this,l=48,f=57,c=96,m=105,h=17,g=46,p=13,y=27,v=8,b=37,D=38,k=39,x=40,T=9,S=116,w=65,O=67,M=86,_=90,W=89,F=!1,C=e.isPlainObject(n)||!n?e.extend(!0,{},a,n):e.extend(!0,{},a),P=0,A=function(e){e.on("open.xdsoft focusin.xdsoft mousedown.xdsoft touchstart",function t(){e.is(":disabled")||e.data("xdsoft_datetimepicker")||(clearTimeout(P),P=setTimeout(function(){e.data("xdsoft_datetimepicker")||s(e),e.off("open.xdsoft focusin.xdsoft mousedown.xdsoft touchstart",t).trigger("open.xdsoft")},100))})};return s=function(a){function i(){var e,t=!1;return C.startDate?t=j.strToDate(C.startDate):(t=C.value||(a&&a.val&&a.val()?a.val():""),t?t=j.strToDateTime(t):C.defaultDate&&(t=j.strToDateTime(C.defaultDate),C.defaultTime&&(e=j.strtotime(C.defaultTime),t.setHours(e.getHours()),t.setMinutes(e.getMinutes())))),t&&j.isValidDate(t)?J.data("changed",!0):t="",t||0}function s(t){var r=function(e,t){var a=e.replace(/([\[\]\/\{\}\(\)\-\.\+]{1})/g,"\\$1").replace(/_/g,"{digit+}").replace(/([0-9]{1})/g,"{digit$1}").replace(/\{digit([0-9]{1})\}/g,"[0-$1_]{1}").replace(/\{digit[\+]\}/g,"[0-9_]{1}");return new RegExp(a).test(t)},n=function(e){try{if(document.selection&&document.selection.createRange){var t=document.selection.createRange();return t.getBookmark().charCodeAt(2)-2}if(e.setSelectionRange)return e.selectionStart}catch(a){return 0}},o=function(e,t){if(e="string"==typeof e||e instanceof String?document.getElementById(e):e,!e)return!1;if(e.createTextRange){var a=e.createTextRange();return a.collapse(!0),a.moveEnd("character",t),a.moveStart("character",t),a.select(),!0}return e.setSelectionRange?(e.setSelectionRange(t,t),!0):!1};t.mask&&a.off("keydown.xdsoft"),t.mask===!0&&(t.mask="undefined"!=typeof moment?t.format.replace(/Y{4}/g,"9999").replace(/Y{2}/g,"99").replace(/M{2}/g,"19").replace(/D{2}/g,"39").replace(/H{2}/g,"29").replace(/m{2}/g,"59").replace(/s{2}/g,"59"):t.format.replace(/Y/g,"9999").replace(/F/g,"9999").replace(/m/g,"19").replace(/d/g,"39").replace(/H/g,"29").replace(/i/g,"59").replace(/s/g,"59")),"string"===e.type(t.mask)&&(r(t.mask,a.val())||(a.val(t.mask.replace(/[0-9]/g,"_")),o(a[0],0)),a.on("keydown.xdsoft",function(i){var s,d,u=this.value,C=i.which;if(C>=l&&f>=C||C>=c&&m>=C||C===v||C===g){for(s=n(this),d=C!==v&&C!==g?String.fromCharCode(C>=c&&m>=C?C-l:C):"_",C!==v&&C!==g||!s||(s-=1,d="_");/[^0-9_]/.test(t.mask.substr(s,1))&&s0;)s+=C===v||C===g?-1:1;if(u=u.substr(0,s)+d+u.substr(s+1),""===e.trim(u))u=t.mask.replace(/[0-9]/g,"_");else if(s===t.mask.length)return i.preventDefault(),!1;for(s+=C===v||C===g?0:1;/[^0-9_]/.test(t.mask.substr(s,1))&&s0;)s+=C===v||C===g?-1:1;r(t.mask,u)?(this.value=u,o(this,s)):""===e.trim(u)?this.value=t.mask.replace(/[0-9]/g,"_"):a.trigger("error_input.xdsoft")}else if(-1!==[w,O,M,_,W].indexOf(C)&&F||-1!==[y,D,x,b,k,S,h,T,p].indexOf(C))return!0;return i.preventDefault(),!1}))}var d,u,P,A,Y,j,H,J=e('
'),z=e(''),I=e('
'),N=e('
'),L=e('
'),E=e('
'),R=E.find(".xdsoft_time_box").eq(0),B=e('
'),V=e(''),G=e('
'),U=e('
'),q=!1,X=0;C.id&&J.attr("id",C.id),C.style&&J.attr("style",C.style),C.weeks&&J.addClass("xdsoft_showweeks"),C.rtl&&J.addClass("xdsoft_rtl"),J.addClass("xdsoft_"+C.theme),J.addClass(C.className),N.find(".xdsoft_month span").after(G),N.find(".xdsoft_year span").after(U),N.find(".xdsoft_month,.xdsoft_year").on("touchstart mousedown.xdsoft",function(t){var a,r,n=e(this).find(".xdsoft_select").eq(0),o=0,i=0,s=n.is(":visible");for(N.find(".xdsoft_select").hide(),j.currentTime&&(o=j.currentTime[e(this).hasClass("xdsoft_month")?"getMonth":"getFullYear"]()),n[s?"hide":"show"](),a=n.find("div.xdsoft_option"),r=0;r=i;)u=new t(i,d,c),l=r.formatDate(i,C.formatDate),i.setDate(i.getDate()+1),void 0!==o[l]?(f=o[l].desc,f&&f.length&&u.desc&&u.desc.length&&(o[l].desc=f+"\n"+u.desc)):o[l]=u}),C.highlightedDates=e.extend(!0,[],o)),n.disabledDates&&e.isArray(n.disabledDates)&&n.disabledDates.length&&(C.disabledDates=e.extend(!0,[],n.disabledDates)),n.disabledWeekDays&&e.isArray(n.disabledWeekDays)&&n.disabledWeekDays.length&&(C.disabledWeekDays=e.extend(!0,[],n.disabledWeekDays)),!C.open&&!C.opened||C.inline||a.trigger("open.xdsoft"),C.inline&&(q=!0,J.addClass("xdsoft_inline"),a.after(J).hide()),C.inverseButton&&(C.next="xdsoft_prev",C.prev="xdsoft_next"),C.datepicker?I.addClass("active"):I.removeClass("active"),C.timepicker?E.addClass("active"):E.removeClass("active"),C.value&&(j.setCurrentTime(C.value),a&&a.val&&a.val(j.str)),C.dayOfWeekStart=isNaN(C.dayOfWeekStart)?0:parseInt(C.dayOfWeekStart,10)%7,C.timepickerScrollbar||R.xdsoftScroller("hide"),C.minDate&&/^[\+\-](.*)$/.test(C.minDate)&&(C.minDate=r.formatDate(j.strToDateTime(C.minDate),C.formatDate)),C.maxDate&&/^[\+\-](.*)$/.test(C.maxDate)&&(C.maxDate=r.formatDate(j.strToDateTime(C.maxDate),C.formatDate)),V.toggle(C.showApplyButton),N.find(".xdsoft_today_button").css("visibility",C.todayButton?"visible":"hidden"),N.find("."+C.prev).css("visibility",C.prevButton?"visible":"hidden"),N.find("."+C.next).css("visibility",C.nextButton?"visible":"hidden"),s(C),C.validateOnBlur&&a.off("blur.xdsoft").on("blur.xdsoft",function(){if(C.allowBlank&&(!e.trim(e(this).val()).length||"string"==typeof C.mask&&e.trim(e(this).val())===C.mask.replace(/[0-9]/g,"_")))e(this).val(null),J.data("xdsoft_datetime").empty();else{var t=r.parseDate(e(this).val(),C.format);if(t)e(this).val(r.formatDate(t,C.format));else{var a=+[e(this).val()[0],e(this).val()[1]].join(""),n=+[e(this).val()[2],e(this).val()[3]].join("");e(this).val(!C.datepicker&&C.timepicker&&a>=0&&24>a&&n>=0&&60>n?[a,n].map(function(e){return e>9?e:"0"+e}).join(":"):r.formatDate(j.now(),C.format))}J.data("xdsoft_datetime").setCurrentTime(e(this).val())}J.trigger("changedatetime.xdsoft"),J.trigger("close.xdsoft")}),C.dayOfWeekStartPrev=0===C.dayOfWeekStart?6:C.dayOfWeekStart-1,J.trigger("xchange.xdsoft").trigger("afterOpen.xdsoft")},J.data("options",C).on("touchstart mousedown.xdsoft",function(e){return e.stopPropagation(),e.preventDefault(),U.hide(),G.hide(),!1}),R.append(B),R.xdsoftScroller(),J.on("afterOpen.xdsoft",function(){R.xdsoftScroller()}),J.append(I).append(E),C.withoutCopyright!==!0&&J.append(z),I.append(N).append(L).append(V),e(C.parentID).append(J),d=function(){var t=this;t.now=function(e){var a,r,n=new Date;return!e&&C.defaultDate&&(a=t.strToDateTime(C.defaultDate),n.setFullYear(a.getFullYear()),n.setMonth(a.getMonth()),n.setDate(a.getDate())),C.yearOffset&&n.setFullYear(n.getFullYear()+C.yearOffset),!e&&C.defaultTime&&(r=t.strtotime(C.defaultTime),n.setHours(r.getHours()),n.setMinutes(r.getMinutes())),n},t.isValidDate=function(e){return"[object Date]"!==Object.prototype.toString.call(e)?!1:!isNaN(e.getTime())},t.setCurrentTime=function(e,a){t.currentTime="string"==typeof e?t.strToDateTime(e):t.isValidDate(e)?e:e||a||!C.allowBlank?t.now():null,J.trigger("xchange.xdsoft")},t.empty=function(){t.currentTime=null},t.getCurrentTime=function(){return t.currentTime},t.nextMonth=function(){(void 0===t.currentTime||null===t.currentTime)&&(t.currentTime=t.now());var a,r=t.currentTime.getMonth()+1;return 12===r&&(t.currentTime.setFullYear(t.currentTime.getFullYear()+1),r=0),a=t.currentTime.getFullYear(),t.currentTime.setDate(Math.min(new Date(t.currentTime.getFullYear(),r+1,0).getDate(),t.currentTime.getDate())),t.currentTime.setMonth(r),C.onChangeMonth&&e.isFunction(C.onChangeMonth)&&C.onChangeMonth.call(J,j.currentTime,J.data("input")),a!==t.currentTime.getFullYear()&&e.isFunction(C.onChangeYear)&&C.onChangeYear.call(J,j.currentTime,J.data("input")),J.trigger("xchange.xdsoft"),r},t.prevMonth=function(){(void 0===t.currentTime||null===t.currentTime)&&(t.currentTime=t.now());var a=t.currentTime.getMonth()-1;return-1===a&&(t.currentTime.setFullYear(t.currentTime.getFullYear()-1),a=11),t.currentTime.setDate(Math.min(new Date(t.currentTime.getFullYear(),a+1,0).getDate(),t.currentTime.getDate())),t.currentTime.setMonth(a),C.onChangeMonth&&e.isFunction(C.onChangeMonth)&&C.onChangeMonth.call(J,j.currentTime,J.data("input")),J.trigger("xchange.xdsoft"),a},t.getWeekOfYear=function(t){if(C.onGetWeekOfYear&&e.isFunction(C.onGetWeekOfYear)){var a=C.onGetWeekOfYear.call(J,t);if("undefined"!=typeof a)return a}var r=new Date(t.getFullYear(),0,1);return 4!=r.getDay()&&r.setMonth(0,1+(4-r.getDay()+7)%7),Math.ceil(((t-r)/864e5+r.getDay()+1)/7)},t.strToDateTime=function(e){var a,n,o=[];return e&&e instanceof Date&&t.isValidDate(e)?e:(o=/^(\+|\-)(.*)$/.exec(e),o&&(o[2]=r.parseDate(o[2],C.formatDate)),o&&o[2]?(a=o[2].getTime()-6e4*o[2].getTimezoneOffset(),n=new Date(t.now(!0).getTime()+parseInt(o[1]+"1",10)*a)):n=e?r.parseDate(e,C.format):t.now(),t.isValidDate(n)||(n=t.now()),n)},t.strToDate=function(e){if(e&&e instanceof Date&&t.isValidDate(e))return e;var a=e?r.parseDate(e,C.formatDate):t.now(!0);return t.isValidDate(a)||(a=t.now(!0)),a},t.strtotime=function(e){if(e&&e instanceof Date&&t.isValidDate(e))return e;var a=e?r.parseDate(e,C.formatTime):t.now(!0);return t.isValidDate(a)||(a=t.now(!0)),a},t.str=function(){return r.formatDate(t.currentTime,C.format)},t.currentTime=this.now()},j=new d,V.on("touchend click",function(e){e.preventDefault(),J.data("changed",!0),j.setCurrentTime(i()),a.val(j.str()),J.trigger("close.xdsoft")}),N.find(".xdsoft_today_button").on("touchend mousedown.xdsoft",function(){J.data("changed",!0),j.setCurrentTime(0,!0),J.trigger("afterOpen.xdsoft")}).on("dblclick.xdsoft",function(){var e,t,r=j.getCurrentTime();r=new Date(r.getFullYear(),r.getMonth(),r.getDate()),e=j.strToDate(C.minDate),e=new Date(e.getFullYear(),e.getMonth(),e.getDate()),e>r||(t=j.strToDate(C.maxDate),t=new Date(t.getFullYear(),t.getMonth(),t.getDate()),r>t||(a.val(j.str()),a.trigger("change"),J.trigger("close.xdsoft")))}),N.find(".xdsoft_prev,.xdsoft_next").on("touchend mousedown.xdsoft",function(){var t=e(this),a=0,r=!1;!function n(e){t.hasClass(C.next)?j.nextMonth():t.hasClass(C.prev)&&j.prevMonth(),C.monthChangeSpinner&&(r||(a=setTimeout(n,e||100)))}(500),e([document.body,window]).on("touchend mouseup.xdsoft",function o(){clearTimeout(a),r=!0,e([document.body,window]).off("touchend mouseup.xdsoft",o)})}),E.find(".xdsoft_prev,.xdsoft_next").on("touchend mousedown.xdsoft",function(){var t=e(this),a=0,r=!1,n=110;!function o(e){var i=R[0].clientHeight,s=B[0].offsetHeight,d=Math.abs(parseInt(B.css("marginTop"),10));t.hasClass(C.next)&&s-i-C.timeHeightInTimePicker>=d?B.css("marginTop","-"+(d+C.timeHeightInTimePicker)+"px"):t.hasClass(C.prev)&&d-C.timeHeightInTimePicker>=0&&B.css("marginTop","-"+(d-C.timeHeightInTimePicker)+"px"),R.trigger("scroll_element.xdsoft_scroller",[Math.abs(parseInt(B[0].style.marginTop,10)/(s-i))]),n=n>10?10:n-10,r||(a=setTimeout(o,e||n))}(500),e([document.body,window]).on("touchend mouseup.xdsoft",function i(){clearTimeout(a),r=!0,e([document.body,window]).off("touchend mouseup.xdsoft",i)})}),u=0,J.on("xchange.xdsoft",function(t){clearTimeout(u),u=setTimeout(function(){if(void 0===j.currentTime||null===j.currentTime){if(C.allowBlank)return;j.currentTime=j.now()}for(var t,i,s,d,u,l,f,c,m,h,g="",p=new Date(j.currentTime.getFullYear(),j.currentTime.getMonth(),1,12,0,0),y=0,v=j.now(),b=!1,D=!1,k=[],x=!0,T="",S="";p.getDay()!==C.dayOfWeekStart;)p.setDate(p.getDate()-1);for(g+="",C.weeks&&(g+=""),t=0;7>t;t+=1)g+="";for(g+="",g+="",C.maxDate!==!1&&(b=j.strToDate(C.maxDate),b=new Date(b.getFullYear(),b.getMonth(),b.getDate(),23,59,59,999)),C.minDate!==!1&&(D=j.strToDate(C.minDate),D=new Date(D.getFullYear(),D.getMonth(),D.getDate()));y0?-1===C.allowDates.indexOf(r.formatDate(p,C.formatDate))&&k.push("xdsoft_disabled"):b!==!1&&p>b||D!==!1&&D>p||c&&c[0]===!1?k.push("xdsoft_disabled"):-1!==C.disabledDates.indexOf(r.formatDate(p,C.formatDate))?k.push("xdsoft_disabled"):-1!==C.disabledWeekDays.indexOf(s)?k.push("xdsoft_disabled"):a.is("[readonly]")&&k.push("xdsoft_disabled"),c&&""!==c[1]&&k.push(c[1]),j.currentTime.getMonth()!==l&&k.push("xdsoft_other_month"),(C.defaultSelect||J.data("changed"))&&r.formatDate(j.currentTime,C.formatDate)===r.formatDate(p,C.formatDate)&&k.push("xdsoft_current"),r.formatDate(v,C.formatDate)===r.formatDate(p,C.formatDate)&&k.push("xdsoft_today"),(0===p.getDay()||6===p.getDay()||-1!==C.weekends.indexOf(r.formatDate(p,C.formatDate)))&&k.push("xdsoft_weekend"),void 0!==C.highlightedDates[r.formatDate(p,C.formatDate)]&&(i=C.highlightedDates[r.formatDate(p,C.formatDate)],k.push(void 0===i.style?"xdsoft_highlighted_default":i.style),h=void 0===i.desc?"":i.desc),C.beforeShowDay&&e.isFunction(C.beforeShowDay)&&k.push(C.beforeShowDay(p)),x&&(g+="",x=!1,C.weeks&&(g+="")),g+='",p.getDay()===C.dayOfWeekStartPrev&&(g+="",x=!0),p.setDate(d+1);if(g+="
"+C.i18n[o].dayOfWeekShort[(t+C.dayOfWeekStart)%7]+"
"+f+"
'+d+"
",L.html(g),N.find(".xdsoft_label span").eq(0).text(C.i18n[o].months[j.currentTime.getMonth()]),N.find(".xdsoft_label span").eq(1).text(j.currentTime.getFullYear()),T="",S="",l="",m=function(t,n){var o,i,s=j.now(),d=C.allowTimes&&e.isArray(C.allowTimes)&&C.allowTimes.length;s.setHours(t),t=parseInt(s.getHours(),10),s.setMinutes(n),n=parseInt(s.getMinutes(),10),o=new Date(j.currentTime),o.setHours(t),o.setMinutes(n),k=[],C.minDateTime!==!1&&C.minDateTime>o||C.maxTime!==!1&&j.strtotime(C.maxTime).getTime()s.getTime()?k.push("xdsoft_disabled"):C.minDateTime!==!1&&C.minDateTime>o||C.disabledMinTime!==!1&&s.getTime()>j.strtotime(C.disabledMinTime).getTime()&&C.disabledMaxTime!==!1&&s.getTime()59||i.getMinutes()===parseInt(n,10))&&(C.defaultSelect||J.data("changed")?k.push("xdsoft_current"):C.initTime&&k.push("xdsoft_init_time")),parseInt(v.getHours(),10)===parseInt(t,10)&&parseInt(v.getMinutes(),10)===parseInt(n,10)&&k.push("xdsoft_today"),T+='
'+r.formatDate(s,C.formatTime)+"
"},C.allowTimes&&e.isArray(C.allowTimes)&&C.allowTimes.length)for(y=0;yt;t+=C.step)S=(10>y?"0":"")+y,l=(10>t?"0":"")+t,m(S,l);for(B.html(T),n="",y=0,y=parseInt(C.yearStart,10)+C.yearOffset;y<=parseInt(C.yearEnd,10)+C.yearOffset;y+=1)n+='
'+y+"
";for(U.children().eq(0).html(n),y=parseInt(C.monthStart,10),n="";y<=parseInt(C.monthEnd,10);y+=1)n+='
'+C.i18n[o].months[y]+"
";G.children().eq(0).html(n),e(J).trigger("generate.xdsoft")},10),t.stopPropagation()}).on("afterOpen.xdsoft",function(){if(C.timepicker){var e,t,a,r;B.find(".xdsoft_current").length?e=".xdsoft_current":B.find(".xdsoft_init_time").length&&(e=".xdsoft_init_time"),e?(t=R[0].clientHeight,a=B[0].offsetHeight,r=B.find(e).index()*C.timeHeightInTimePicker+1,r>a-t&&(r=a-t),R.trigger("scroll_element.xdsoft_scroller",[parseInt(r,10)/(a-t)])):R.trigger("scroll_element.xdsoft_scroller",[0])}}),P=0,L.on("touchend click.xdsoft","td",function(t){t.stopPropagation(),P+=1;var r=e(this),n=j.currentTime;return(void 0===n||null===n)&&(j.currentTime=j.now(),n=j.currentTime),r.hasClass("xdsoft_disabled")?!1:(n.setDate(1),n.setFullYear(r.data("year")),n.setMonth(r.data("month")),n.setDate(r.data("date")),J.trigger("select.xdsoft",[n]),a.val(j.str()),C.onSelectDate&&e.isFunction(C.onSelectDate)&&C.onSelectDate.call(J,j.currentTime,J.data("input"),t),J.data("changed",!0),J.trigger("xchange.xdsoft"),J.trigger("changedatetime.xdsoft"),(P>1||C.closeOnDateSelect===!0||C.closeOnDateSelect===!1&&!C.timepicker)&&!C.inline&&J.trigger("close.xdsoft"),void setTimeout(function(){P=0},200))}),B.on("touchend click.xdsoft","div",function(t){t.stopPropagation();var a=e(this),r=j.currentTime;return(void 0===r||null===r)&&(j.currentTime=j.now(),r=j.currentTime),a.hasClass("xdsoft_disabled")?!1:(r.setHours(a.data("hour")),r.setMinutes(a.data("minute")),J.trigger("select.xdsoft",[r]),J.data("input").val(j.str()),C.onSelectTime&&e.isFunction(C.onSelectTime)&&C.onSelectTime.call(J,j.currentTime,J.data("input"),t),J.data("changed",!0),J.trigger("xchange.xdsoft"),J.trigger("changedatetime.xdsoft"),void(C.inline!==!0&&C.closeOnTimeSelect===!0&&J.trigger("close.xdsoft")))}),I.on("mousewheel.xdsoft",function(e){return C.scrollMonth?(e.deltaY<0?j.nextMonth():j.prevMonth(),!1):!0}),a.on("mousewheel.xdsoft",function(e){return C.scrollInput?!C.datepicker&&C.timepicker?(A=B.find(".xdsoft_current").length?B.find(".xdsoft_current").eq(0).index():0,A+e.deltaY>=0&&A+e.deltaYc+m?(l="bottom",r=c+m-t.top):r-=m):r+a.offsetHeight>c+m&&(r=t.top-a.offsetHeight+1),0>r&&(r=0),n+a.offsetWidth>u&&(n=u-a.offsetWidth)),i=J[0],H(i,function(e){var t;return t=window.getComputedStyle(e).getPropertyValue("position"),"relative"===t&&u>=e.offsetWidth?(n-=(u-e.offsetWidth)/2,!1):void 0}),f={position:o,left:n,top:"",bottom:""},f[l]=r,J.css(f)},J.on("open.xdsoft",function(t){var a=!0;C.onShow&&e.isFunction(C.onShow)&&(a=C.onShow.call(J,j.currentTime,J.data("input"),t)),a!==!1&&(J.show(),Y(),e(window).off("resize.xdsoft",Y).on("resize.xdsoft",Y),C.closeOnWithoutClick&&e([document.body,window]).on("touchstart mousedown.xdsoft",function r(){J.trigger("close.xdsoft"),e([document.body,window]).off("touchstart mousedown.xdsoft",r)}))}).on("close.xdsoft",function(t){var a=!0;N.find(".xdsoft_month,.xdsoft_year").find(".xdsoft_select").hide(),C.onClose&&e.isFunction(C.onClose)&&(a=C.onClose.call(J,j.currentTime,J.data("input"),t)),a===!1||C.opened||C.inline||J.hide(),t.stopPropagation()}).on("toggle.xdsoft",function(){J.trigger(J.is(":visible")?"close.xdsoft":"open.xdsoft")}).data("input",a),X=0,J.data("xdsoft_datetime",j),J.setOptions(C),j.setCurrentTime(i()),a.data("xdsoft_datetimepicker",J).on("open.xdsoft focusin.xdsoft mousedown.xdsoft touchstart",function(){a.is(":disabled")||a.data("xdsoft_datetimepicker").is(":visible")&&C.closeOnInputClick||(clearTimeout(X),X=setTimeout(function(){a.is(":disabled")||(q=!0,j.setCurrentTime(i(),!0),C.mask&&s(C),J.trigger("open.xdsoft"))},100))}).on("keydown.xdsoft",function(t){var a,r=t.which;return-1!==[p].indexOf(r)&&C.enterLikeTab?(a=e("input:visible,textarea:visible,button:visible,a:visible"),J.trigger("close.xdsoft"),a.eq(a.index(this)+1).focus(),!1):-1!==[T].indexOf(r)?(J.trigger("close.xdsoft"),!0):void 0}).on("blur.xdsoft",function(){J.trigger("close.xdsoft")})},d=function(t){var a=t.data("xdsoft_datetimepicker");a&&(a.data("xdsoft_datetime",null),a.remove(),t.data("xdsoft_datetimepicker",null).off(".xdsoft"),e(window).off("resize.xdsoft"),e([window,document.body]).off("mousedown.xdsoft touchstart"),t.unmousewheel&&t.unmousewheel())},e(document).off("keydown.xdsoftctrl keyup.xdsoftctrl").on("keydown.xdsoftctrl",function(e){e.keyCode===h&&(F=!0)}).on("keyup.xdsoftctrl",function(e){e.keyCode===h&&(F=!1)}),this.each(function(){var t,a=e(this).data("xdsoft_datetimepicker");if(a){if("string"===e.type(n))switch(n){case"show":e(this).select().focus(),a.trigger("open.xdsoft");break;case"hide":a.trigger("close.xdsoft");break;case"toggle":a.trigger("toggle.xdsoft");break;case"destroy":d(e(this));break;case"reset":this.value=this.defaultValue,this.value&&a.data("xdsoft_datetime").isValidDate(r.parseDate(this.value,C.format))||a.data("changed",!1),a.data("xdsoft_datetime").setCurrentTime(this.value);break;case"validate":t=a.data("input"),t.trigger("blur.xdsoft");break;default:a[n]&&e.isFunction(a[n])&&(u=a[n](i))}else a.setOptions(n);return 0}"string"!==e.type(n)&&(!C.lazyInit||C.open||C.inline?s(e(this)):A(e(this)))}),u},e.fn.datetimepicker.defaults=a}),function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?module.exports=e:e(jQuery)}(function(e){function t(t){var i=t||window.event,s=d.call(arguments,1),u=0,f=0,c=0,m=0,h=0,g=0;if(t=e.event.fix(i),t.type="mousewheel","detail"in i&&(c=-1*i.detail),"wheelDelta"in i&&(c=i.wheelDelta),"wheelDeltaY"in i&&(c=i.wheelDeltaY),"wheelDeltaX"in i&&(f=-1*i.wheelDeltaX),"axis"in i&&i.axis===i.HORIZONTAL_AXIS&&(f=-1*c,c=0),u=0===c?f:c,"deltaY"in i&&(c=-1*i.deltaY,u=c),"deltaX"in i&&(f=i.deltaX,0===c&&(u=-1*f)),0!==c||0!==f){if(1===i.deltaMode){var p=e.data(this,"mousewheel-line-height");u*=p,c*=p,f*=p}else if(2===i.deltaMode){var y=e.data(this,"mousewheel-page-height");u*=y,c*=y,f*=y}if(m=Math.max(Math.abs(c),Math.abs(f)),(!o||o>m)&&(o=m,r(i,m)&&(o/=40)),r(i,m)&&(u/=40,f/=40,c/=40),u=Math[u>=1?"floor":"ceil"](u/o),f=Math[f>=1?"floor":"ceil"](f/o),c=Math[c>=1?"floor":"ceil"](c/o),l.settings.normalizeOffset&&this.getBoundingClientRect){var v=this.getBoundingClientRect();h=t.clientX-v.left,g=t.clientY-v.top}return t.deltaX=f,t.deltaY=c,t.deltaFactor=o,t.offsetX=h,t.offsetY=g,t.deltaMode=0,s.unshift(t,u,f,c),n&&clearTimeout(n),n=setTimeout(a,200),(e.event.dispatch||e.event.handle).apply(this,s)}}function a(){o=null}function r(e,t){return l.settings.adjustOldDeltas&&"mousewheel"===e.type&&t%120===0}var n,o,i=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],s="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],d=Array.prototype.slice;if(e.event.fixHooks)for(var u=i.length;u;)e.event.fixHooks[i[--u]]=e.event.mouseHooks;var l=e.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var a=s.length;a;)this.addEventListener(s[--a],t,!1);else this.onmousewheel=t;e.data(this,"mousewheel-line-height",l.getLineHeight(this)),e.data(this,"mousewheel-page-height",l.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var a=s.length;a;)this.removeEventListener(s[--a],t,!1);else this.onmousewheel=null;e.removeData(this,"mousewheel-line-height"),e.removeData(this,"mousewheel-page-height")},getLineHeight:function(t){var a=e(t),r=a["offsetParent"in e.fn?"offsetParent":"parent"]();return r.length||(r=e("body")),parseInt(r.css("fontSize"),10)||parseInt(a.css("fontSize"),10)||16},getPageHeight:function(t){return e(t).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};e.fn.extend({mousewheel:function(e){return e?this.bind("mousewheel",e):this.trigger("mousewheel")},unmousewheel:function(e){return this.unbind("mousewheel",e)}})}); \ No newline at end of file diff --git a/documize/section/github/github.go b/documize/section/github/github.go index ce00d74f..befce79e 100644 --- a/documize/section/github/github.go +++ b/documize/section/github/github.go @@ -20,7 +20,6 @@ import ( "net/http" "net/url" "strings" - "time" "github.com/documize/community/documize/api/request" "github.com/documize/community/documize/section/provider" @@ -177,8 +176,6 @@ func (t *Provider) Command(w http.ResponseWriter, r *http.Request) { owners = sortOwners(owners) - //fmt.Printf("DEBUG owners %#v\n", owners) - provider.WriteJSON(w, owners) case "repos": @@ -193,7 +190,7 @@ func (t *Provider) Command(w http.ResponseWriter, r *http.Request) { return } - var repos []gogithub.Repository + var repos []*gogithub.Repository if config.Owner == *me.Login { repos, _, err = client.Repositories.List(config.Owner, nil) } else { @@ -251,6 +248,30 @@ func (t *Provider) Command(w http.ResponseWriter, r *http.Request) { provider.WriteJSON(w, render) + case "labels": + if config.Owner == "" || config.Repo == "" { + provider.WriteJSON(w, []githubBranch{}) // we have nothing to return + return + } + labels, _, err := client.Issues.ListLabels(config.Owner, config.Repo, + &gogithub.ListOptions{PerPage: 100}) + if err != nil { + log.Error("github get labels:", err) + provider.WriteError(w, "github", err) + return + } + render := make([]githubBranch, len(labels)) + for kc, vb := range labels { + render[kc] = githubBranch{ + Name: *vb.Name, + ID: fmt.Sprintf("%s:%s:%s", config.Owner, config.Repo, *vb.Name), + Included: false, + Color: *vb.Color, + } + } + + provider.WriteJSON(w, render) + default: log.ErrorString("Github connector unknown method: " + method) provider.WriteEmpty(w) @@ -286,6 +307,7 @@ func (*Provider) getIssueNum(client *gogithub.Client, config githubConfig) ([]gi } ret = append(ret, githubIssueActivity{ Name: n, + Event: "TITLE", Message: *issue.Title, // TODO move? Date: issue.UpdatedAt.Format("January 2 2006, 15:04"), Avatar: a, @@ -293,6 +315,7 @@ func (*Provider) getIssueNum(client *gogithub.Client, config githubConfig) ([]gi }) ret = append(ret, githubIssueActivity{ Name: n, + Event: "DESCRIPTION", Message: *issue.Body, Date: issue.UpdatedAt.Format("January 2 2006, 15:04"), Avatar: a, @@ -302,32 +325,59 @@ func (*Provider) getIssueNum(client *gogithub.Client, config githubConfig) ([]gi return ret, err } - guff, _, err := client.Issues.ListComments(config.Owner, config.Repo, config.IssueNum, - &gogithub.IssueListCommentsOptions{ListOptions: gogithub.ListOptions{PerPage: 100}}) + opts := &gogithub.ListOptions{PerPage: config.BranchLines} + + guff, _, err := client.Issues.ListIssueTimeline(config.Owner, config.Repo, config.IssueNum, opts) if err != nil { return ret, err } for _, v := range guff { - n := "" - a := "" - p := v.User - if p != nil { - if p.Name != nil { - n = *p.Name + if config.SincePtr == nil || v.CreatedAt.After(*config.SincePtr) { + var n, a, m, u string + + p := v.Actor + if p != nil { + if p.Name != nil { + n = *p.Name + } + if p.AvatarURL != nil { + a = *p.AvatarURL + } } - if p.AvatarURL != nil { - a = *p.AvatarURL + + u = fmt.Sprintf("https://github.com/%s/%s/issues/%d#event-%d", + config.Owner, config.Repo, config.IssueNum, *v.ID) + + if *v.Event == "commented" { + ic, _, err := client.Issues.GetComment(config.Owner, config.Repo, *v.ID) + if err != nil { + log.ErrorString("github error fetching issue event comment: " + err.Error()) + } else { + m = *ic.Body + u = *ic.HTMLURL + p := ic.User + if p != nil { + if p.Name != nil { + n = *p.Name + } + if p.AvatarURL != nil { + a = *p.AvatarURL + } + } + } } + + ret = append(ret, githubIssueActivity{ + Name: n, + Event: *v.Event, + Message: m, + Date: v.CreatedAt.Format("January 2 2006, 15:04"), + Avatar: a, + URL: u, + }) } - ret = append(ret, githubIssueActivity{ - Name: n, - Message: *v.Body, - Date: v.UpdatedAt.Format("January 2 2006, 15:04"), - Avatar: a, - URL: *v.HTMLURL, - }) } return ret, nil @@ -336,11 +386,23 @@ func (*Provider) getIssueNum(client *gogithub.Client, config githubConfig) ([]gi func (*Provider) getIssues(client *gogithub.Client, config githubConfig) ([]githubIssue, error) { - guff, _, err := client.Issues.ListByRepo(config.Owner, config.Repo, - &gogithub.IssueListByRepoOptions{ListOptions: gogithub.ListOptions{PerPage: 100}}) + opts := &gogithub.IssueListByRepoOptions{ + ListOptions: gogithub.ListOptions{PerPage: config.BranchLines}} + + if config.SincePtr != nil { + opts.Since = *config.SincePtr + } + + for _, lab := range config.Lists { + if lab.Included { + opts.Labels = append(opts.Labels, lab.Name) + } + } ret := []githubIssue{} + guff, _, err := client.Issues.ListByRepo(config.Owner, config.Repo, opts) + if err != nil { return ret, err } @@ -357,12 +419,17 @@ func (*Provider) getIssues(client *gogithub.Client, config githubConfig) ([]gith a = *p.AvatarURL } } + l := "" + for _, ll := range v.Labels { + l += `` + *ll.Name + ` ` + } ret = append(ret, githubIssue{ Name: n, Message: *v.Title, Date: v.UpdatedAt.Format("January 2 2006, 15:04"), Avatar: a, URL: *v.HTMLURL, + Labels: l, }) } @@ -376,11 +443,8 @@ func (*Provider) getCommits(client *gogithub.Client, config githubConfig) ([]git SHA: config.Branch, ListOptions: gogithub.ListOptions{PerPage: config.BranchLines}} - var since time.Time - - err := since.UnmarshalText([]byte(config.BranchSince)) // TODO date Picker format - if err == nil { - opts.Since = since + if config.SincePtr != nil { + opts.Since = *config.SincePtr } guff, _, err := client.Repositories.ListCommits(config.Owner, config.Repo, opts) @@ -508,7 +572,7 @@ func (t *Provider) Refresh(configJSON, data string) string { } // Render ... just returns the data given, suitably formatted -func (*Provider) Render(config, data string) string { +func (p *Provider) Render(config, data string) string { var err error payload := githubRender{} @@ -524,6 +588,10 @@ func (*Provider) Render(config, data string) string { c.Clean() payload.Config = c payload.Repo = c.RepoInfo + payload.Limit = c.BranchLines + if len(c.BranchSince) > 0 { + payload.DateMessage = ", created after " + c.BranchSince + } switch c.ReportInfo.ID { case "issuenum_data": @@ -537,6 +605,19 @@ func (*Provider) Render(config, data string) string { return "Documize internal github json umarshall issue activity data error: " + err.Error() } } + + opt := &gogithub.MarkdownOptions{Mode: "gfm", Context: c.Owner + "/" + c.Repo} + client := p.githubClient(c) + for k, v := range raw { + if v.Event == "commented" { + output, _, err := client.Markdown(v.Message, opt) + if err != nil { + log.Error("convert commented text to markdown", err) + } else { + raw[k].Message = output + } + } + } payload.IssueNumActivity = raw case "issues_data": @@ -550,6 +631,15 @@ func (*Provider) Render(config, data string) string { } } payload.Issues = raw + if len(c.Lists) > 0 { + for _, v := range c.Lists { + if v.Included { + payload.ShowList = true + break + } + } + payload.List = c.Lists + } default: // to handle legacy data, this handles commits raw := []githubBranchCommits{} diff --git a/documize/section/github/model.go b/documize/section/github/model.go index 0f39c61b..16e2d42c 100644 --- a/documize/section/github/model.go +++ b/documize/section/github/model.go @@ -12,25 +12,33 @@ package github import ( - //"github.com/documize/community/wordsmith/log" - "strings" + "time" + + "github.com/documize/community/wordsmith/log" ) type githubRender struct { Config githubConfig Repo githubRepo + List []githubBranch + ShowList bool BranchCommits []githubBranchCommits CommitCount int Issues []githubIssue IssueNum int IssueNumActivity []githubIssueActivity + Limit int + DateMessage string } var renderTemplates = map[string]string{ "commits_data": `
-

There are {{ .CommitCount }} commits for branch {{.Config.Branch}} of repository {{.Repo.Name}}.

+

+ There are {{ .CommitCount }} commits for branch {{.Config.Branch}} of repository {{.Repo.Name}}. + Up to {{ .Limit }} items are shown{{ .DateMessage }}. +

{{range $data := .BranchCommits}}
@@ -58,7 +66,19 @@ var renderTemplates = map[string]string{ `, "issues_data": `
-

The issues for repository {{.Repo.Name}}.

+

+ The open issues for repository {{.Repo.Name}} + {{if .ShowList}} + with label(s) + {{range $label := .List}} + {{if $label.Included}} + {{$label.Name}} + {{end}} + {{end}} + {{end}} + . + Up to {{ .Limit }} items are shown{{ .DateMessage }}. +

    {{range $data := .Issues}} @@ -69,7 +89,9 @@ var renderTemplates = map[string]string{
{{$data.Message}}
-
{{$data.Name}} committed on {{$data.Date}}
+
+ {{$data.Name}} committed on {{$data.Date}} {{$data.Labels}} +
@@ -81,7 +103,10 @@ var renderTemplates = map[string]string{ `, "issuenum_data": `
-

Activity for issue #{{.IssueNum}} in repository {{.Repo.Name}}.

+

+ Activity for issue #{{.IssueNum}} in repository {{.Repo.Name}}. + Up to {{ .Limit }} items are shown{{ .DateMessage }}. +

    {{range $data := .IssueNumActivity}} @@ -91,7 +116,7 @@ var renderTemplates = map[string]string{ @{{$data.Name}}
-
{{$data.Message}}
+
{{$data.Event}}: {{$data.Message}}
{{$data.Name}} committed on {{$data.Date}}
@@ -129,6 +154,7 @@ type githubBranch struct { Name string `json:"name"` Included bool `json:"included"` URL string `json:"url"` + Color string `json:"color,omitempty"` } type githubBranchCommits struct { @@ -151,10 +177,12 @@ type githubIssue struct { URL string `json:"url"` Name string `json:"name"` Avatar string `json:"avatar"` + Labels string `json:"labels"` } type githubIssueActivity struct { Date string `json:"date"` + Event string `json:"event"` Message string `json:"message"` URL string `json:"url"` Name string `json:"name"` @@ -169,7 +197,8 @@ type githubConfig struct { Branch string `json:"branch"` BranchURL string `json:"branchURL"` BranchSince string `json:"branchSince,omitempty"` - BranchLines int `json:"branchLines,omitempty"` + SincePtr *time.Time `json:"-"` + BranchLines int `json:"branchLines,omitempty,string"` OwnerInfo githubOwner `json:"owner"` RepoInfo githubRepo `json:"repo"` ReportInfo githubReport `json:"report"` @@ -191,12 +220,19 @@ func (c *githubConfig) Clean() { break } } - // var e error - // c.IssueNum, e = strconv.Atoi(c.IssueNumString) - // if e != nil { - // log.ErrorString("github clean issue number: " + e.Error()) - // c.IssueNum = 1 - // } + if len(c.BranchSince) >= len("yyyy/mm/dd hh:ss") { + var since time.Time + tt := []byte("yyyy-mm-ddThh:mm:00Z") + for _, i := range []int{0, 1, 2, 3, 5, 6, 8, 9, 11, 12, 14, 15} { + tt[i] = byte(c.BranchSince[i]) + } + err := since.UnmarshalText(tt) + if err != nil { + log.ErrorString("Date unmarshall '" + c.BranchSince + "'->'" + string(tt) + "' error: " + err.Error()) + } else { + c.SincePtr = &since + } + } } type githubCallbackT struct { diff --git a/vendor/github.com/google/go-github/.gitignore b/vendor/github.com/google/go-github/.gitignore deleted file mode 100644 index 9ed3b07c..00000000 --- a/vendor/github.com/google/go-github/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.test diff --git a/vendor/github.com/google/go-github/.travis.yml b/vendor/github.com/google/go-github/.travis.yml deleted file mode 100644 index 42b299fe..00000000 --- a/vendor/github.com/google/go-github/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -sudo: false -language: go -go: - - 1.5.4 - - 1.6.2 - - tip -matrix: - include: - - go: 1.4.3 - script: - - go get -t -v ./... - - go test -v -race ./... - allow_failures: - - go: tip - fast_finish: true -install: - - # Do nothing. This is needed to prevent default install action "go get -t -v ./..." from happening here (we want it to happen inside script step). -script: - - go get -t -v ./... - - diff -u <(echo -n) <(gofmt -d -s .) - - go tool vet . - - go test -v -race ./... diff --git a/vendor/github.com/google/go-github/AUTHORS b/vendor/github.com/google/go-github/AUTHORS index d296221c..64d9743c 100644 --- a/vendor/github.com/google/go-github/AUTHORS +++ b/vendor/github.com/google/go-github/AUTHORS @@ -2,6 +2,7 @@ # This file is distinct from the CONTRIBUTORS files. # See the latter for an explanation. +Ainsley Chong Akeda Bagus Alec Thomas Alexander Harkness @@ -10,6 +11,7 @@ Andreas Garnæs Andrew Ryabchun Arıl Bozoluk Austin Dizzy +Beshr Kayali Beyang Liu Björn Häuser Brad Harris @@ -30,6 +32,7 @@ erwinvaneyk Filippo Valsorda Francis Fredrik Jönsson +Garrett Squire Georgy Buranov Google Inc. griffin_stewie diff --git a/vendor/github.com/google/go-github/CONTRIBUTORS b/vendor/github.com/google/go-github/CONTRIBUTORS index 13794cb2..e10c67c8 100644 --- a/vendor/github.com/google/go-github/CONTRIBUTORS +++ b/vendor/github.com/google/go-github/CONTRIBUTORS @@ -10,6 +10,7 @@ # copyright _license_. You retain the copyright on your # contributions. +Ainsley Chong Akeda Bagus Alec Thomas Alex Bramley @@ -20,6 +21,7 @@ Andreas Garnæs Andrew Ryabchun Arıl Bozoluk Austin Dizzy +Beshr Kayali Beyang Liu Billy Lynch Björn Häuser @@ -45,6 +47,7 @@ erwinvaneyk Filippo Valsorda Francis Fredrik Jönsson +Garrett Squire Georgy Buranov Glenn Lewis griffin_stewie diff --git a/vendor/github.com/google/go-github/github/activity_events.go b/vendor/github.com/google/go-github/github/activity_events.go index be7e4b27..a0e5f088 100644 --- a/vendor/github.com/google/go-github/github/activity_events.go +++ b/vendor/github.com/google/go-github/github/activity_events.go @@ -85,7 +85,7 @@ func (e *Event) Payload() (payload interface{}) { // ListEvents drinks from the firehose of all public events across GitHub. // // GitHub API docs: http://developer.github.com/v3/activity/events/#list-public-events -func (s *ActivityService) ListEvents(opt *ListOptions) ([]Event, *Response, error) { +func (s *ActivityService) ListEvents(opt *ListOptions) ([]*Event, *Response, error) { u, err := addOptions("events", opt) if err != nil { return nil, nil, err @@ -96,7 +96,7 @@ func (s *ActivityService) ListEvents(opt *ListOptions) ([]Event, *Response, erro return nil, nil, err } - events := new([]Event) + events := new([]*Event) resp, err := s.client.Do(req, events) if err != nil { return nil, resp, err @@ -108,7 +108,7 @@ func (s *ActivityService) ListEvents(opt *ListOptions) ([]Event, *Response, erro // ListRepositoryEvents lists events for a repository. // // GitHub API docs: http://developer.github.com/v3/activity/events/#list-repository-events -func (s *ActivityService) ListRepositoryEvents(owner, repo string, opt *ListOptions) ([]Event, *Response, error) { +func (s *ActivityService) ListRepositoryEvents(owner, repo string, opt *ListOptions) ([]*Event, *Response, error) { u := fmt.Sprintf("repos/%v/%v/events", owner, repo) u, err := addOptions(u, opt) if err != nil { @@ -120,7 +120,7 @@ func (s *ActivityService) ListRepositoryEvents(owner, repo string, opt *ListOpti return nil, nil, err } - events := new([]Event) + events := new([]*Event) resp, err := s.client.Do(req, events) if err != nil { return nil, resp, err @@ -132,7 +132,7 @@ func (s *ActivityService) ListRepositoryEvents(owner, repo string, opt *ListOpti // ListIssueEventsForRepository lists issue events for a repository. // // GitHub API docs: http://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository -func (s *ActivityService) ListIssueEventsForRepository(owner, repo string, opt *ListOptions) ([]Event, *Response, error) { +func (s *ActivityService) ListIssueEventsForRepository(owner, repo string, opt *ListOptions) ([]*Event, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/events", owner, repo) u, err := addOptions(u, opt) if err != nil { @@ -144,7 +144,7 @@ func (s *ActivityService) ListIssueEventsForRepository(owner, repo string, opt * return nil, nil, err } - events := new([]Event) + events := new([]*Event) resp, err := s.client.Do(req, events) if err != nil { return nil, resp, err @@ -156,7 +156,7 @@ func (s *ActivityService) ListIssueEventsForRepository(owner, repo string, opt * // ListEventsForRepoNetwork lists public events for a network of repositories. // // GitHub API docs: http://developer.github.com/v3/activity/events/#list-public-events-for-a-network-of-repositories -func (s *ActivityService) ListEventsForRepoNetwork(owner, repo string, opt *ListOptions) ([]Event, *Response, error) { +func (s *ActivityService) ListEventsForRepoNetwork(owner, repo string, opt *ListOptions) ([]*Event, *Response, error) { u := fmt.Sprintf("networks/%v/%v/events", owner, repo) u, err := addOptions(u, opt) if err != nil { @@ -168,7 +168,7 @@ func (s *ActivityService) ListEventsForRepoNetwork(owner, repo string, opt *List return nil, nil, err } - events := new([]Event) + events := new([]*Event) resp, err := s.client.Do(req, events) if err != nil { return nil, resp, err @@ -180,7 +180,7 @@ func (s *ActivityService) ListEventsForRepoNetwork(owner, repo string, opt *List // ListEventsForOrganization lists public events for an organization. // // GitHub API docs: http://developer.github.com/v3/activity/events/#list-public-events-for-an-organization -func (s *ActivityService) ListEventsForOrganization(org string, opt *ListOptions) ([]Event, *Response, error) { +func (s *ActivityService) ListEventsForOrganization(org string, opt *ListOptions) ([]*Event, *Response, error) { u := fmt.Sprintf("orgs/%v/events", org) u, err := addOptions(u, opt) if err != nil { @@ -192,7 +192,7 @@ func (s *ActivityService) ListEventsForOrganization(org string, opt *ListOptions return nil, nil, err } - events := new([]Event) + events := new([]*Event) resp, err := s.client.Do(req, events) if err != nil { return nil, resp, err @@ -205,7 +205,7 @@ func (s *ActivityService) ListEventsForOrganization(org string, opt *ListOptions // true, only public events will be returned. // // GitHub API docs: http://developer.github.com/v3/activity/events/#list-events-performed-by-a-user -func (s *ActivityService) ListEventsPerformedByUser(user string, publicOnly bool, opt *ListOptions) ([]Event, *Response, error) { +func (s *ActivityService) ListEventsPerformedByUser(user string, publicOnly bool, opt *ListOptions) ([]*Event, *Response, error) { var u string if publicOnly { u = fmt.Sprintf("users/%v/events/public", user) @@ -222,7 +222,7 @@ func (s *ActivityService) ListEventsPerformedByUser(user string, publicOnly bool return nil, nil, err } - events := new([]Event) + events := new([]*Event) resp, err := s.client.Do(req, events) if err != nil { return nil, resp, err @@ -235,7 +235,7 @@ func (s *ActivityService) ListEventsPerformedByUser(user string, publicOnly bool // true, only public events will be returned. // // GitHub API docs: http://developer.github.com/v3/activity/events/#list-events-that-a-user-has-received -func (s *ActivityService) ListEventsReceivedByUser(user string, publicOnly bool, opt *ListOptions) ([]Event, *Response, error) { +func (s *ActivityService) ListEventsReceivedByUser(user string, publicOnly bool, opt *ListOptions) ([]*Event, *Response, error) { var u string if publicOnly { u = fmt.Sprintf("users/%v/received_events/public", user) @@ -252,7 +252,7 @@ func (s *ActivityService) ListEventsReceivedByUser(user string, publicOnly bool, return nil, nil, err } - events := new([]Event) + events := new([]*Event) resp, err := s.client.Do(req, events) if err != nil { return nil, resp, err @@ -265,7 +265,7 @@ func (s *ActivityService) ListEventsReceivedByUser(user string, publicOnly bool, // must be authenticated as the user to view this. // // GitHub API docs: http://developer.github.com/v3/activity/events/#list-events-for-an-organization -func (s *ActivityService) ListUserEventsForOrganization(org, user string, opt *ListOptions) ([]Event, *Response, error) { +func (s *ActivityService) ListUserEventsForOrganization(org, user string, opt *ListOptions) ([]*Event, *Response, error) { u := fmt.Sprintf("users/%v/events/orgs/%v", user, org) u, err := addOptions(u, opt) if err != nil { @@ -277,7 +277,7 @@ func (s *ActivityService) ListUserEventsForOrganization(org, user string, opt *L return nil, nil, err } - events := new([]Event) + events := new([]*Event) resp, err := s.client.Do(req, events) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/activity_events_test.go b/vendor/github.com/google/go-github/github/activity_events_test.go index 8d1d1ff3..f8ffea71 100644 --- a/vendor/github.com/google/go-github/github/activity_events_test.go +++ b/vendor/github.com/google/go-github/github/activity_events_test.go @@ -31,7 +31,7 @@ func TestActivityService_ListEvents(t *testing.T) { t.Errorf("Activities.ListEvents returned error: %v", err) } - want := []Event{{ID: String("1")}, {ID: String("2")}} + want := []*Event{{ID: String("1")}, {ID: String("2")}} if !reflect.DeepEqual(events, want) { t.Errorf("Activities.ListEvents returned %+v, want %+v", events, want) } @@ -55,7 +55,7 @@ func TestActivityService_ListRepositoryEvents(t *testing.T) { t.Errorf("Activities.ListRepositoryEvents returned error: %v", err) } - want := []Event{{ID: String("1")}, {ID: String("2")}} + want := []*Event{{ID: String("1")}, {ID: String("2")}} if !reflect.DeepEqual(events, want) { t.Errorf("Activities.ListRepositoryEvents returned %+v, want %+v", events, want) } @@ -84,7 +84,7 @@ func TestActivityService_ListIssueEventsForRepository(t *testing.T) { t.Errorf("Activities.ListIssueEventsForRepository returned error: %v", err) } - want := []Event{{ID: String("1")}, {ID: String("2")}} + want := []*Event{{ID: String("1")}, {ID: String("2")}} if !reflect.DeepEqual(events, want) { t.Errorf("Activities.ListIssueEventsForRepository returned %+v, want %+v", events, want) } @@ -113,7 +113,7 @@ func TestActivityService_ListEventsForRepoNetwork(t *testing.T) { t.Errorf("Activities.ListEventsForRepoNetwork returned error: %v", err) } - want := []Event{{ID: String("1")}, {ID: String("2")}} + want := []*Event{{ID: String("1")}, {ID: String("2")}} if !reflect.DeepEqual(events, want) { t.Errorf("Activities.ListEventsForRepoNetwork returned %+v, want %+v", events, want) } @@ -142,7 +142,7 @@ func TestActivityService_ListEventsForOrganization(t *testing.T) { t.Errorf("Activities.ListEventsForOrganization returned error: %v", err) } - want := []Event{{ID: String("1")}, {ID: String("2")}} + want := []*Event{{ID: String("1")}, {ID: String("2")}} if !reflect.DeepEqual(events, want) { t.Errorf("Activities.ListEventsForOrganization returned %+v, want %+v", events, want) } @@ -171,7 +171,7 @@ func TestActivityService_ListEventsPerformedByUser_all(t *testing.T) { t.Errorf("Events.ListPerformedByUser returned error: %v", err) } - want := []Event{{ID: String("1")}, {ID: String("2")}} + want := []*Event{{ID: String("1")}, {ID: String("2")}} if !reflect.DeepEqual(events, want) { t.Errorf("Events.ListPerformedByUser returned %+v, want %+v", events, want) } @@ -191,7 +191,7 @@ func TestActivityService_ListEventsPerformedByUser_publicOnly(t *testing.T) { t.Errorf("Events.ListPerformedByUser returned error: %v", err) } - want := []Event{{ID: String("1")}, {ID: String("2")}} + want := []*Event{{ID: String("1")}, {ID: String("2")}} if !reflect.DeepEqual(events, want) { t.Errorf("Events.ListPerformedByUser returned %+v, want %+v", events, want) } @@ -220,7 +220,7 @@ func TestActivityService_ListEventsReceivedByUser_all(t *testing.T) { t.Errorf("Events.ListReceivedByUser returned error: %v", err) } - want := []Event{{ID: String("1")}, {ID: String("2")}} + want := []*Event{{ID: String("1")}, {ID: String("2")}} if !reflect.DeepEqual(events, want) { t.Errorf("Events.ListReceivedUser returned %+v, want %+v", events, want) } @@ -240,7 +240,7 @@ func TestActivityService_ListEventsReceivedByUser_publicOnly(t *testing.T) { t.Errorf("Events.ListReceivedByUser returned error: %v", err) } - want := []Event{{ID: String("1")}, {ID: String("2")}} + want := []*Event{{ID: String("1")}, {ID: String("2")}} if !reflect.DeepEqual(events, want) { t.Errorf("Events.ListReceivedByUser returned %+v, want %+v", events, want) } @@ -269,7 +269,7 @@ func TestActivityService_ListUserEventsForOrganization(t *testing.T) { t.Errorf("Activities.ListUserEventsForOrganization returned error: %v", err) } - want := []Event{{ID: String("1")}, {ID: String("2")}} + want := []*Event{{ID: String("1")}, {ID: String("2")}} if !reflect.DeepEqual(events, want) { t.Errorf("Activities.ListUserEventsForOrganization returned %+v, want %+v", events, want) } diff --git a/vendor/github.com/google/go-github/github/activity_notifications.go b/vendor/github.com/google/go-github/github/activity_notifications.go index 290b9542..8890388d 100644 --- a/vendor/github.com/google/go-github/github/activity_notifications.go +++ b/vendor/github.com/google/go-github/github/activity_notifications.go @@ -42,12 +42,14 @@ type NotificationListOptions struct { Participating bool `url:"participating,omitempty"` Since time.Time `url:"since,omitempty"` Before time.Time `url:"before,omitempty"` + + ListOptions } // ListNotifications lists all notifications for the authenticated user. // // GitHub API Docs: https://developer.github.com/v3/activity/notifications/#list-your-notifications -func (s *ActivityService) ListNotifications(opt *NotificationListOptions) ([]Notification, *Response, error) { +func (s *ActivityService) ListNotifications(opt *NotificationListOptions) ([]*Notification, *Response, error) { u := fmt.Sprintf("notifications") u, err := addOptions(u, opt) if err != nil { @@ -59,7 +61,7 @@ func (s *ActivityService) ListNotifications(opt *NotificationListOptions) ([]Not return nil, nil, err } - var notifications []Notification + var notifications []*Notification resp, err := s.client.Do(req, ¬ifications) if err != nil { return nil, resp, err @@ -72,7 +74,7 @@ func (s *ActivityService) ListNotifications(opt *NotificationListOptions) ([]Not // for the authenticated user. // // GitHub API Docs: https://developer.github.com/v3/activity/notifications/#list-your-notifications-in-a-repository -func (s *ActivityService) ListRepositoryNotifications(owner, repo string, opt *NotificationListOptions) ([]Notification, *Response, error) { +func (s *ActivityService) ListRepositoryNotifications(owner, repo string, opt *NotificationListOptions) ([]*Notification, *Response, error) { u := fmt.Sprintf("repos/%v/%v/notifications", owner, repo) u, err := addOptions(u, opt) if err != nil { @@ -84,7 +86,7 @@ func (s *ActivityService) ListRepositoryNotifications(owner, repo string, opt *N return nil, nil, err } - var notifications []Notification + var notifications []*Notification resp, err := s.client.Do(req, ¬ifications) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/activity_notifications_test.go b/vendor/github.com/google/go-github/github/activity_notifications_test.go index f72ee413..81b4ffae 100644 --- a/vendor/github.com/google/go-github/github/activity_notifications_test.go +++ b/vendor/github.com/google/go-github/github/activity_notifications_test.go @@ -41,7 +41,7 @@ func TestActivityService_ListNotification(t *testing.T) { t.Errorf("Activity.ListNotifications returned error: %v", err) } - want := []Notification{{ID: String("1"), Subject: &NotificationSubject{Title: String("t")}}} + want := []*Notification{{ID: String("1"), Subject: &NotificationSubject{Title: String("t")}}} if !reflect.DeepEqual(notifications, want) { t.Errorf("Activity.ListNotifications returned %+v, want %+v", notifications, want) } @@ -61,7 +61,7 @@ func TestActivityService_ListRepositoryNotification(t *testing.T) { t.Errorf("Activity.ListRepositoryNotifications returned error: %v", err) } - want := []Notification{{ID: String("1")}} + want := []*Notification{{ID: String("1")}} if !reflect.DeepEqual(notifications, want) { t.Errorf("Activity.ListRepositoryNotifications returned %+v, want %+v", notifications, want) } diff --git a/vendor/github.com/google/go-github/github/activity_star.go b/vendor/github.com/google/go-github/github/activity_star.go index 080d6545..5df6814a 100644 --- a/vendor/github.com/google/go-github/github/activity_star.go +++ b/vendor/github.com/google/go-github/github/activity_star.go @@ -22,7 +22,7 @@ type Stargazer struct { // ListStargazers lists people who have starred the specified repo. // // GitHub API Docs: https://developer.github.com/v3/activity/starring/#list-stargazers -func (s *ActivityService) ListStargazers(owner, repo string, opt *ListOptions) ([]Stargazer, *Response, error) { +func (s *ActivityService) ListStargazers(owner, repo string, opt *ListOptions) ([]*Stargazer, *Response, error) { u := fmt.Sprintf("repos/%s/%s/stargazers", owner, repo) u, err := addOptions(u, opt) if err != nil { @@ -37,7 +37,7 @@ func (s *ActivityService) ListStargazers(owner, repo string, opt *ListOptions) ( // TODO: remove custom Accept header when this API fully launches req.Header.Set("Accept", mediaTypeStarringPreview) - stargazers := new([]Stargazer) + stargazers := new([]*Stargazer) resp, err := s.client.Do(req, stargazers) if err != nil { return nil, resp, err @@ -64,7 +64,7 @@ type ActivityListStarredOptions struct { // will list the starred repositories for the authenticated user. // // GitHub API docs: http://developer.github.com/v3/activity/starring/#list-repositories-being-starred -func (s *ActivityService) ListStarred(user string, opt *ActivityListStarredOptions) ([]StarredRepository, *Response, error) { +func (s *ActivityService) ListStarred(user string, opt *ActivityListStarredOptions) ([]*StarredRepository, *Response, error) { var u string if user != "" { u = fmt.Sprintf("users/%v/starred", user) @@ -84,7 +84,7 @@ func (s *ActivityService) ListStarred(user string, opt *ActivityListStarredOptio // TODO: remove custom Accept header when this API fully launches req.Header.Set("Accept", mediaTypeStarringPreview) - repos := new([]StarredRepository) + repos := new([]*StarredRepository) resp, err := s.client.Do(req, repos) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/activity_star_test.go b/vendor/github.com/google/go-github/github/activity_star_test.go index cd687231..4c0767a5 100644 --- a/vendor/github.com/google/go-github/github/activity_star_test.go +++ b/vendor/github.com/google/go-github/github/activity_star_test.go @@ -32,7 +32,7 @@ func TestActivityService_ListStargazers(t *testing.T) { t.Errorf("Activity.ListStargazers returned error: %v", err) } - want := []Stargazer{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, User: &User{ID: Int(1)}}} + want := []*Stargazer{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, User: &User{ID: Int(1)}}} if !reflect.DeepEqual(stargazers, want) { t.Errorf("Activity.ListStargazers returned %+v, want %+v", stargazers, want) } @@ -53,7 +53,7 @@ func TestActivityService_ListStarred_authenticatedUser(t *testing.T) { t.Errorf("Activity.ListStarred returned error: %v", err) } - want := []StarredRepository{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, Repository: &Repository{ID: Int(1)}}} + want := []*StarredRepository{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, Repository: &Repository{ID: Int(1)}}} if !reflect.DeepEqual(repos, want) { t.Errorf("Activity.ListStarred returned %+v, want %+v", repos, want) } @@ -80,7 +80,7 @@ func TestActivityService_ListStarred_specifiedUser(t *testing.T) { t.Errorf("Activity.ListStarred returned error: %v", err) } - want := []StarredRepository{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, Repository: &Repository{ID: Int(2)}}} + want := []*StarredRepository{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, Repository: &Repository{ID: Int(2)}}} if !reflect.DeepEqual(repos, want) { t.Errorf("Activity.ListStarred returned %+v, want %+v", repos, want) } diff --git a/vendor/github.com/google/go-github/github/activity_watching.go b/vendor/github.com/google/go-github/github/activity_watching.go index c002b3b1..6bf91dd3 100644 --- a/vendor/github.com/google/go-github/github/activity_watching.go +++ b/vendor/github.com/google/go-github/github/activity_watching.go @@ -25,7 +25,7 @@ type Subscription struct { // ListWatchers lists watchers of a particular repo. // // GitHub API Docs: http://developer.github.com/v3/activity/watching/#list-watchers -func (s *ActivityService) ListWatchers(owner, repo string, opt *ListOptions) ([]User, *Response, error) { +func (s *ActivityService) ListWatchers(owner, repo string, opt *ListOptions) ([]*User, *Response, error) { u := fmt.Sprintf("repos/%s/%s/subscribers", owner, repo) u, err := addOptions(u, opt) if err != nil { @@ -37,7 +37,7 @@ func (s *ActivityService) ListWatchers(owner, repo string, opt *ListOptions) ([] return nil, nil, err } - watchers := new([]User) + watchers := new([]*User) resp, err := s.client.Do(req, watchers) if err != nil { return nil, resp, err @@ -50,7 +50,7 @@ func (s *ActivityService) ListWatchers(owner, repo string, opt *ListOptions) ([] // the empty string will fetch watched repos for the authenticated user. // // GitHub API Docs: https://developer.github.com/v3/activity/watching/#list-repositories-being-watched -func (s *ActivityService) ListWatched(user string, opt *ListOptions) ([]Repository, *Response, error) { +func (s *ActivityService) ListWatched(user string, opt *ListOptions) ([]*Repository, *Response, error) { var u string if user != "" { u = fmt.Sprintf("users/%v/subscriptions", user) @@ -67,7 +67,7 @@ func (s *ActivityService) ListWatched(user string, opt *ListOptions) ([]Reposito return nil, nil, err } - watched := new([]Repository) + watched := new([]*Repository) resp, err := s.client.Do(req, watched) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/activity_watching_test.go b/vendor/github.com/google/go-github/github/activity_watching_test.go index a8a4a46a..8989fd3e 100644 --- a/vendor/github.com/google/go-github/github/activity_watching_test.go +++ b/vendor/github.com/google/go-github/github/activity_watching_test.go @@ -31,7 +31,7 @@ func TestActivityService_ListWatchers(t *testing.T) { t.Errorf("Activity.ListWatchers returned error: %v", err) } - want := []User{{ID: Int(1)}} + want := []*User{{ID: Int(1)}} if !reflect.DeepEqual(watchers, want) { t.Errorf("Activity.ListWatchers returned %+v, want %+v", watchers, want) } @@ -54,7 +54,7 @@ func TestActivityService_ListWatched_authenticatedUser(t *testing.T) { t.Errorf("Activity.ListWatched returned error: %v", err) } - want := []Repository{{ID: Int(1)}} + want := []*Repository{{ID: Int(1)}} if !reflect.DeepEqual(watched, want) { t.Errorf("Activity.ListWatched returned %+v, want %+v", watched, want) } @@ -73,12 +73,11 @@ func TestActivityService_ListWatched_specifiedUser(t *testing.T) { }) watched, _, err := client.Activity.ListWatched("u", &ListOptions{Page: 2}) - if err != nil { t.Errorf("Activity.ListWatched returned error: %v", err) } - want := []Repository{{ID: Int(1)}} + want := []*Repository{{ID: Int(1)}} if !reflect.DeepEqual(watched, want) { t.Errorf("Activity.ListWatched returned %+v, want %+v", watched, want) } diff --git a/vendor/github.com/google/go-github/github/authorizations.go b/vendor/github.com/google/go-github/github/authorizations.go index cfe63490..2839f93f 100644 --- a/vendor/github.com/google/go-github/github/authorizations.go +++ b/vendor/github.com/google/go-github/github/authorizations.go @@ -35,6 +35,9 @@ const ( ScopeReadPublicKey Scope = "read:public_key" ScopeWritePublicKey Scope = "write:public_key" ScopeAdminPublicKey Scope = "admin:public_key" + ScopeReadGPGKey Scope = "read:gpg_key" + ScopeWriteGPGKey Scope = "write:gpg_key" + ScopeAdminGPGKey Scope = "admin:gpg_key" ) // AuthorizationsService handles communication with the authorization related @@ -82,6 +85,20 @@ func (a AuthorizationApp) String() string { return Stringify(a) } +// Grant represents an OAuth application that has been granted access to an account. +type Grant struct { + ID *int `json:"id,omitempty"` + URL *string `json:"url,omitempty"` + App *AuthorizationApp `json:"app,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + UpdatedAt *Timestamp `json:"updated_at,omitempty"` + Scopes []string `json:"scopes,omitempty"` +} + +func (g Grant) String() string { + return Stringify(g) +} + // AuthorizationRequest represents a request to create an authorization. type AuthorizationRequest struct { Scopes []Scope `json:"scopes,omitempty"` @@ -119,7 +136,7 @@ func (a AuthorizationUpdateRequest) String() string { // List the authorizations for the authenticated user. // // GitHub API docs: https://developer.github.com/v3/oauth_authorizations/#list-your-authorizations -func (s *AuthorizationsService) List(opt *ListOptions) ([]Authorization, *Response, error) { +func (s *AuthorizationsService) List(opt *ListOptions) ([]*Authorization, *Response, error) { u := "authorizations" u, err := addOptions(u, opt) if err != nil { @@ -131,7 +148,7 @@ func (s *AuthorizationsService) List(opt *ListOptions) ([]Authorization, *Respon return nil, nil, err } - auths := new([]Authorization) + auths := new([]*Authorization) resp, err := s.client.Do(req, auths) if err != nil { return nil, resp, err @@ -318,3 +335,67 @@ func (s *AuthorizationsService) Revoke(clientID string, token string) (*Response return s.client.Do(req, nil) } + +// ListGrants lists the set of OAuth applications that have been granted +// access to a user's account. This will return one entry for each application +// that has been granted access to the account, regardless of the number of +// tokens an application has generated for the user. +// +// GitHub API docs: https://developer.github.com/v3/oauth_authorizations/#list-your-grants +func (s *AuthorizationsService) ListGrants() ([]*Grant, *Response, error) { + req, err := s.client.NewRequest("GET", "applications/grants", nil) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeOAuthGrantAuthorizationsPreview) + + grants := []*Grant{} + resp, err := s.client.Do(req, &grants) + if err != nil { + return nil, resp, err + } + + return grants, resp, err +} + +// GetGrant gets a single OAuth application grant. +// +// GitHub API docs: https://developer.github.com/v3/oauth_authorizations/#get-a-single-grant +func (s *AuthorizationsService) GetGrant(id int) (*Grant, *Response, error) { + u := fmt.Sprintf("applications/grants/%d", id) + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeOAuthGrantAuthorizationsPreview) + + grant := new(Grant) + resp, err := s.client.Do(req, grant) + if err != nil { + return nil, resp, err + } + + return grant, resp, err +} + +// DeleteGrant deletes an OAuth application grant. Deleting an application's +// grant will also delete all OAuth tokens associated with the application for +// the user. +// +// GitHub API docs: https://developer.github.com/v3/oauth_authorizations/#delete-a-grant +func (s *AuthorizationsService) DeleteGrant(id int) (*Response, error) { + u := fmt.Sprintf("applications/grants/%d", id) + req, err := s.client.NewRequest("DELETE", u, nil) + if err != nil { + return nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeOAuthGrantAuthorizationsPreview) + + return s.client.Do(req, nil) +} diff --git a/vendor/github.com/google/go-github/github/authorizations_test.go b/vendor/github.com/google/go-github/github/authorizations_test.go index 813762a2..b3d4e91c 100644 --- a/vendor/github.com/google/go-github/github/authorizations_test.go +++ b/vendor/github.com/google/go-github/github/authorizations_test.go @@ -29,7 +29,7 @@ func TestAuthorizationsService_List(t *testing.T) { t.Errorf("Authorizations.List returned error: %v", err) } - want := []Authorization{{ID: Int(1)}} + want := []*Authorization{{ID: Int(1)}} if !reflect.DeepEqual(got, want) { t.Errorf("Authorizations.List returned %+v, want %+v", *got[0].ID, *want[0].ID) } @@ -249,3 +249,60 @@ func TestAuthorizationsService_Revoke(t *testing.T) { t.Errorf("Authorizations.Revoke returned error: %v", err) } } + +func TestListGrants(t *testing.T) { + setup() + defer teardown() + + mux.HandleFunc("/applications/grants", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testHeader(t, r, "Accept", mediaTypeOAuthGrantAuthorizationsPreview) + fmt.Fprint(w, `[{"id": 1}]`) + }) + + got, _, err := client.Authorizations.ListGrants() + if err != nil { + t.Errorf("OAuthAuthorizations.ListGrants returned error: %v", err) + } + + want := []*Grant{{ID: Int(1)}} + if !reflect.DeepEqual(got, want) { + t.Errorf("OAuthAuthorizations.ListGrants = %+v, want %+v", got, want) + } +} + +func TestGetGrant(t *testing.T) { + setup() + defer teardown() + + mux.HandleFunc("/applications/grants/1", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testHeader(t, r, "Accept", mediaTypeOAuthGrantAuthorizationsPreview) + fmt.Fprint(w, `{"id": 1}`) + }) + + got, _, err := client.Authorizations.GetGrant(1) + if err != nil { + t.Errorf("OAuthAuthorizations.GetGrant returned error: %v", err) + } + + want := &Grant{ID: Int(1)} + if !reflect.DeepEqual(got, want) { + t.Errorf("OAuthAuthorizations.GetGrant = %+v, want %+v", got, want) + } +} + +func TestDeleteGrant(t *testing.T) { + setup() + defer teardown() + + mux.HandleFunc("/applications/grants/1", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "DELETE") + testHeader(t, r, "Accept", mediaTypeOAuthGrantAuthorizationsPreview) + }) + + _, err := client.Authorizations.DeleteGrant(1) + if err != nil { + t.Errorf("OAuthAuthorizations.DeleteGrant returned error: %v", err) + } +} diff --git a/vendor/github.com/google/go-github/github/doc.go b/vendor/github.com/google/go-github/github/doc.go index 0d32d498..6c6f53a2 100644 --- a/vendor/github.com/google/go-github/github/doc.go +++ b/vendor/github.com/google/go-github/github/doc.go @@ -116,7 +116,7 @@ PullRequestListOptions). Pages information is available via Response struct. ListOptions: github.ListOptions{PerPage: 10}, } // get all pages of results - var allRepos []github.Repository + var allRepos []*github.Repository for { repos, resp, err := client.Repositories.ListByOrg("github", opt) if err != nil { diff --git a/vendor/github.com/google/go-github/github/event_types.go b/vendor/github.com/google/go-github/github/event_types.go index 6f7202ed..f3e163d2 100644 --- a/vendor/github.com/google/go-github/github/event_types.go +++ b/vendor/github.com/google/go-github/github/event_types.go @@ -316,12 +316,19 @@ func (p PushEvent) String() string { // PushEventCommit represents a git commit in a GitHub PushEvent. type PushEventCommit struct { - SHA *string `json:"sha,omitempty"` - Message *string `json:"message,omitempty"` - Author *CommitAuthor `json:"author,omitempty"` + Message *string `json:"message,omitempty"` + Author *CommitAuthor `json:"author,omitempty"` + URL *string `json:"url,omitempty"` + Distinct *bool `json:"distinct,omitempty"` + + // The following fields are only populated by Events API. + SHA *string `json:"sha,omitempty"` + + // The following fields are only populated by Webhook events. + ID *string `json:"id,omitempty"` + TreeID *string `json:"tree_id,omitempty"` + Timestamp *Timestamp `json:"timestamp,omitempty"` Committer *CommitAuthor `json:"committer,omitempty"` - URL *string `json:"url,omitempty"` - Distinct *bool `json:"distinct,omitempty"` Added []string `json:"added,omitempty"` Removed []string `json:"removed,omitempty"` Modified []string `json:"modified,omitempty"` diff --git a/vendor/github.com/google/go-github/github/examples_test.go b/vendor/github.com/google/go-github/github/examples_test.go new file mode 100644 index 00000000..7b754cd2 --- /dev/null +++ b/vendor/github.com/google/go-github/github/examples_test.go @@ -0,0 +1,75 @@ +// Copyright 2016 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github_test + +import ( + "fmt" + "log" + + "github.com/google/go-github/github" +) + +func ExampleClient_Markdown() { + client := github.NewClient(nil) + + input := "# heading #\n\nLink to issue #1" + opt := &github.MarkdownOptions{Mode: "gfm", Context: "google/go-github"} + + output, _, err := client.Markdown(input, opt) + if err != nil { + fmt.Println(err) + } + + fmt.Println(output) +} + +func ExampleRepositoriesService_GetReadme() { + client := github.NewClient(nil) + + readme, _, err := client.Repositories.GetReadme("google", "go-github", nil) + if err != nil { + fmt.Println(err) + return + } + + content, err := readme.GetContent() + if err != nil { + fmt.Println(err) + return + } + + fmt.Printf("google/go-github README:\n%v\n", content) +} + +func ExampleRepositoriesService_List() { + client := github.NewClient(nil) + + user := "willnorris" + opt := &github.RepositoryListOptions{Type: "owner", Sort: "updated", Direction: "desc"} + + repos, _, err := client.Repositories.List(user, opt) + if err != nil { + fmt.Println(err) + } + + fmt.Printf("Recently updated repositories by %q: %v", user, github.Stringify(repos)) +} + +func ExampleUsersService_ListAll() { + client := github.NewClient(nil) + opts := &github.UserListOptions{} + for { + users, _, err := client.Users.ListAll(opts) + if err != nil { + log.Fatalf("error listing users: %v", err) + } + if len(users) == 0 { + break + } + opts.Since = *users[len(users)-1].ID + // Process users... + } +} diff --git a/vendor/github.com/google/go-github/github/gists.go b/vendor/github.com/google/go-github/github/gists.go index a662d354..b452bcb4 100644 --- a/vendor/github.com/google/go-github/github/gists.go +++ b/vendor/github.com/google/go-github/github/gists.go @@ -52,6 +52,32 @@ func (g GistFile) String() string { return Stringify(g) } +// GistCommit represents a commit on a gist. +type GistCommit struct { + URL *string `json:"url,omitempty"` + Version *string `json:"version,omitempty"` + User *User `json:"user,omitempty"` + ChangeStatus *CommitStats `json:"change_status,omitempty"` + CommitedAt *Timestamp `json:"commited_at,omitempty"` +} + +func (gc GistCommit) String() string { + return Stringify(gc) +} + +// GistFork represents a fork of a gist. +type GistFork struct { + URL *string `json:"url,omitempty"` + User *User `json:"user,omitempty"` + ID *string `json:"id,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + UpdatedAt *Timestamp `json:"updated_at,omitempty"` +} + +func (gf GistFork) String() string { + return Stringify(gf) +} + // GistListOptions specifies the optional parameters to the // GistsService.List, GistsService.ListAll, and GistsService.ListStarred methods. type GistListOptions struct { @@ -67,7 +93,7 @@ type GistListOptions struct { // user. // // GitHub API docs: http://developer.github.com/v3/gists/#list-gists -func (s *GistsService) List(user string, opt *GistListOptions) ([]Gist, *Response, error) { +func (s *GistsService) List(user string, opt *GistListOptions) ([]*Gist, *Response, error) { var u string if user != "" { u = fmt.Sprintf("users/%v/gists", user) @@ -84,7 +110,7 @@ func (s *GistsService) List(user string, opt *GistListOptions) ([]Gist, *Respons return nil, nil, err } - gists := new([]Gist) + gists := new([]*Gist) resp, err := s.client.Do(req, gists) if err != nil { return nil, resp, err @@ -96,7 +122,7 @@ func (s *GistsService) List(user string, opt *GistListOptions) ([]Gist, *Respons // ListAll lists all public gists. // // GitHub API docs: http://developer.github.com/v3/gists/#list-gists -func (s *GistsService) ListAll(opt *GistListOptions) ([]Gist, *Response, error) { +func (s *GistsService) ListAll(opt *GistListOptions) ([]*Gist, *Response, error) { u, err := addOptions("gists/public", opt) if err != nil { return nil, nil, err @@ -107,7 +133,7 @@ func (s *GistsService) ListAll(opt *GistListOptions) ([]Gist, *Response, error) return nil, nil, err } - gists := new([]Gist) + gists := new([]*Gist) resp, err := s.client.Do(req, gists) if err != nil { return nil, resp, err @@ -119,7 +145,7 @@ func (s *GistsService) ListAll(opt *GistListOptions) ([]Gist, *Response, error) // ListStarred lists starred gists of authenticated user. // // GitHub API docs: http://developer.github.com/v3/gists/#list-gists -func (s *GistsService) ListStarred(opt *GistListOptions) ([]Gist, *Response, error) { +func (s *GistsService) ListStarred(opt *GistListOptions) ([]*Gist, *Response, error) { u, err := addOptions("gists/starred", opt) if err != nil { return nil, nil, err @@ -130,7 +156,7 @@ func (s *GistsService) ListStarred(opt *GistListOptions) ([]Gist, *Response, err return nil, nil, err } - gists := new([]Gist) + gists := new([]*Gist) resp, err := s.client.Do(req, gists) if err != nil { return nil, resp, err @@ -211,6 +237,25 @@ func (s *GistsService) Edit(id string, gist *Gist) (*Gist, *Response, error) { return g, resp, err } +// ListCommits lists commits of a gist. +// +// Github API docs: https://developer.github.com/v3/gists/#list-gist-commits +func (s *GistsService) ListCommits(id string) ([]*GistCommit, *Response, error) { + u := fmt.Sprintf("gists/%v/commits", id) + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + gistCommits := new([]*GistCommit) + resp, err := s.client.Do(req, gistCommits) + if err != nil { + return nil, resp, err + } + + return *gistCommits, resp, err +} + // Delete a gist. // // GitHub API docs: http://developer.github.com/v3/gists/#delete-a-gist @@ -279,3 +324,22 @@ func (s *GistsService) Fork(id string) (*Gist, *Response, error) { return g, resp, err } + +// ListForks lists forks of a gist. +// +// Github API docs: https://developer.github.com/v3/gists/#list-gist-forks +func (s *GistsService) ListForks(id string) ([]*GistFork, *Response, error) { + u := fmt.Sprintf("gists/%v/forks", id) + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + gistForks := new([]*GistFork) + resp, err := s.client.Do(req, gistForks) + if err != nil { + return nil, resp, err + } + + return *gistForks, resp, err +} diff --git a/vendor/github.com/google/go-github/github/gists_comments.go b/vendor/github.com/google/go-github/github/gists_comments.go index c5c21bde..95a7fc76 100644 --- a/vendor/github.com/google/go-github/github/gists_comments.go +++ b/vendor/github.com/google/go-github/github/gists_comments.go @@ -26,7 +26,7 @@ func (g GistComment) String() string { // ListComments lists all comments for a gist. // // GitHub API docs: http://developer.github.com/v3/gists/comments/#list-comments-on-a-gist -func (s *GistsService) ListComments(gistID string, opt *ListOptions) ([]GistComment, *Response, error) { +func (s *GistsService) ListComments(gistID string, opt *ListOptions) ([]*GistComment, *Response, error) { u := fmt.Sprintf("gists/%v/comments", gistID) u, err := addOptions(u, opt) if err != nil { @@ -38,7 +38,7 @@ func (s *GistsService) ListComments(gistID string, opt *ListOptions) ([]GistComm return nil, nil, err } - comments := new([]GistComment) + comments := new([]*GistComment) resp, err := s.client.Do(req, comments) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/gists_comments_test.go b/vendor/github.com/google/go-github/github/gists_comments_test.go index b2bbf23f..eacd89f9 100644 --- a/vendor/github.com/google/go-github/github/gists_comments_test.go +++ b/vendor/github.com/google/go-github/github/gists_comments_test.go @@ -25,12 +25,11 @@ func TestGistsService_ListComments(t *testing.T) { opt := &ListOptions{Page: 2} comments, _, err := client.Gists.ListComments("1", opt) - if err != nil { t.Errorf("Gists.Comments returned error: %v", err) } - want := []GistComment{{ID: Int(1)}} + want := []*GistComment{{ID: Int(1)}} if !reflect.DeepEqual(comments, want) { t.Errorf("Gists.ListComments returned %+v, want %+v", comments, want) } @@ -51,7 +50,6 @@ func TestGistsService_GetComment(t *testing.T) { }) comment, _, err := client.Gists.GetComment("1", 2) - if err != nil { t.Errorf("Gists.GetComment returned error: %v", err) } diff --git a/vendor/github.com/google/go-github/github/gists_test.go b/vendor/github.com/google/go-github/github/gists_test.go index 57312012..0b081ae9 100644 --- a/vendor/github.com/google/go-github/github/gists_test.go +++ b/vendor/github.com/google/go-github/github/gists_test.go @@ -30,12 +30,11 @@ func TestGistsService_List_specifiedUser(t *testing.T) { opt := &GistListOptions{Since: time.Date(2013, time.January, 1, 0, 0, 0, 0, time.UTC)} gists, _, err := client.Gists.List("u", opt) - if err != nil { t.Errorf("Gists.List returned error: %v", err) } - want := []Gist{{ID: String("1")}} + want := []*Gist{{ID: String("1")}} if !reflect.DeepEqual(gists, want) { t.Errorf("Gists.List returned %+v, want %+v", gists, want) } @@ -55,7 +54,7 @@ func TestGistsService_List_authenticatedUser(t *testing.T) { t.Errorf("Gists.List returned error: %v", err) } - want := []Gist{{ID: String("1")}} + want := []*Gist{{ID: String("1")}} if !reflect.DeepEqual(gists, want) { t.Errorf("Gists.List returned %+v, want %+v", gists, want) } @@ -82,12 +81,11 @@ func TestGistsService_ListAll(t *testing.T) { opt := &GistListOptions{Since: time.Date(2013, time.January, 1, 0, 0, 0, 0, time.UTC)} gists, _, err := client.Gists.ListAll(opt) - if err != nil { t.Errorf("Gists.ListAll returned error: %v", err) } - want := []Gist{{ID: String("1")}} + want := []*Gist{{ID: String("1")}} if !reflect.DeepEqual(gists, want) { t.Errorf("Gists.ListAll returned %+v, want %+v", gists, want) } @@ -109,12 +107,11 @@ func TestGistsService_ListStarred(t *testing.T) { opt := &GistListOptions{Since: time.Date(2013, time.January, 1, 0, 0, 0, 0, time.UTC)} gists, _, err := client.Gists.ListStarred(opt) - if err != nil { t.Errorf("Gists.ListStarred returned error: %v", err) } - want := []Gist{{ID: String("1")}} + want := []*Gist{{ID: String("1")}} if !reflect.DeepEqual(gists, want) { t.Errorf("Gists.ListStarred returned %+v, want %+v", gists, want) } @@ -130,7 +127,6 @@ func TestGistsService_Get(t *testing.T) { }) gist, _, err := client.Gists.Get("1") - if err != nil { t.Errorf("Gists.Get returned error: %v", err) } @@ -156,7 +152,6 @@ func TestGistsService_GetRevision(t *testing.T) { }) gist, _, err := client.Gists.GetRevision("1", "s") - if err != nil { t.Errorf("Gists.Get returned error: %v", err) } @@ -286,6 +281,53 @@ func TestGistsService_Edit_invalidID(t *testing.T) { testURLParseError(t, err) } +func TestGistsService_ListCommits(t *testing.T) { + setup() + defer teardown() + + mux.HandleFunc("/gists/1/commits", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testFormValues(t, r, nil) + fmt.Fprint(w, ` + [ + { + "url": "https://api.github.com/gists/1/1", + "version": "1", + "user": { + "id": 1 + }, + "change_status": { + "deletions": 0, + "additions": 180, + "total": 180 + }, + "commited_at": "2010-01-01T00:00:00Z" + } + ] + `) + }) + + gistCommits, _, err := client.Gists.ListCommits("1") + if err != nil { + t.Errorf("Gists.ListCommits returned error: %v", err) + } + + want := []*GistCommit{{ + URL: String("https://api.github.com/gists/1/1"), + Version: String("1"), + User: &User{ID: Int(1)}, + CommitedAt: &Timestamp{time.Date(2010, 1, 1, 00, 00, 00, 0, time.UTC)}, + ChangeStatus: &CommitStats{ + Additions: Int(180), + Deletions: Int(0), + Total: Int(180), + }}} + + if !reflect.DeepEqual(gistCommits, want) { + t.Errorf("Gists.ListCommits returned %+v, want %+v", gistCommits, want) + } +} + func TestGistsService_Delete(t *testing.T) { setup() defer teardown() @@ -394,7 +436,6 @@ func TestGistsService_Fork(t *testing.T) { }) gist, _, err := client.Gists.Fork("1") - if err != nil { t.Errorf("Gists.Fork returned error: %v", err) } @@ -405,6 +446,42 @@ func TestGistsService_Fork(t *testing.T) { } } +func TestGistsService_ListForks(t *testing.T) { + setup() + defer teardown() + + mux.HandleFunc("/gists/1/forks", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testFormValues(t, r, nil) + fmt.Fprint(w, ` + [ + {"url": "https://api.github.com/gists/1", + "user": {"id": 1}, + "id": "1", + "created_at": "2010-01-01T00:00:00Z", + "updated_at": "2013-01-01T00:00:00Z" + } + ] + `) + }) + + gistForks, _, err := client.Gists.ListForks("1") + if err != nil { + t.Errorf("Gists.ListForks returned error: %v", err) + } + + want := []*GistFork{{ + URL: String("https://api.github.com/gists/1"), + ID: String("1"), + User: &User{ID: Int(1)}, + CreatedAt: &Timestamp{time.Date(2010, 1, 1, 00, 00, 00, 0, time.UTC)}, + UpdatedAt: &Timestamp{time.Date(2013, 1, 1, 00, 00, 00, 0, time.UTC)}}} + + if !reflect.DeepEqual(gistForks, want) { + t.Errorf("Gists.ListForks returned %+v, want %+v", gistForks, want) + } +} + func TestGistsService_Fork_invalidID(t *testing.T) { _, _, err := client.Gists.Fork("%") testURLParseError(t, err) diff --git a/vendor/github.com/google/go-github/github/git_commits.go b/vendor/github.com/google/go-github/github/git_commits.go index 41e7ff9d..0bcad41d 100644 --- a/vendor/github.com/google/go-github/github/git_commits.go +++ b/vendor/github.com/google/go-github/github/git_commits.go @@ -10,16 +10,25 @@ import ( "time" ) +// SignatureVerification represents GPG signature verification. +type SignatureVerification struct { + Verified *bool `json:"verified,omitempty"` + Reason *string `json:"reason,omitempty"` + Signature *string `json:"signature,omitempty"` + Payload *string `json:"payload,omitempty"` +} + // Commit represents a GitHub commit. type Commit struct { - SHA *string `json:"sha,omitempty"` - Author *CommitAuthor `json:"author,omitempty"` - Committer *CommitAuthor `json:"committer,omitempty"` - Message *string `json:"message,omitempty"` - Tree *Tree `json:"tree,omitempty"` - Parents []Commit `json:"parents,omitempty"` - Stats *CommitStats `json:"stats,omitempty"` - URL *string `json:"url,omitempty"` + SHA *string `json:"sha,omitempty"` + Author *CommitAuthor `json:"author,omitempty"` + Committer *CommitAuthor `json:"committer,omitempty"` + Message *string `json:"message,omitempty"` + Tree *Tree `json:"tree,omitempty"` + Parents []Commit `json:"parents,omitempty"` + Stats *CommitStats `json:"stats,omitempty"` + URL *string `json:"url,omitempty"` + Verification *SignatureVerification `json:"verification,omitempty"` // CommentCount is the number of GitHub comments on the commit. This // is only populated for requests that fetch GitHub data like @@ -56,6 +65,9 @@ func (s *GitService) GetCommit(owner string, repo string, sha string) (*Commit, return nil, nil, err } + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeGitSigningPreview) + c := new(Commit) resp, err := s.client.Do(req, c) if err != nil { diff --git a/vendor/github.com/google/go-github/github/git_commits_test.go b/vendor/github.com/google/go-github/github/git_commits_test.go index 538f5236..566ac4f9 100644 --- a/vendor/github.com/google/go-github/github/git_commits_test.go +++ b/vendor/github.com/google/go-github/github/git_commits_test.go @@ -19,6 +19,7 @@ func TestGitService_GetCommit(t *testing.T) { mux.HandleFunc("/repos/o/r/git/commits/s", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") + testHeader(t, r, "Accept", mediaTypeGitSigningPreview) fmt.Fprint(w, `{"sha":"s","message":"m","author":{"name":"n"}}`) }) diff --git a/vendor/github.com/google/go-github/github/git_refs.go b/vendor/github.com/google/go-github/github/git_refs.go index 3d2f6c8a..16cbd6b3 100644 --- a/vendor/github.com/google/go-github/github/git_refs.go +++ b/vendor/github.com/google/go-github/github/git_refs.go @@ -75,7 +75,7 @@ type ReferenceListOptions struct { // ListRefs lists all refs in a repository. // // GitHub API docs: http://developer.github.com/v3/git/refs/#get-all-references -func (s *GitService) ListRefs(owner, repo string, opt *ReferenceListOptions) ([]Reference, *Response, error) { +func (s *GitService) ListRefs(owner, repo string, opt *ReferenceListOptions) ([]*Reference, *Response, error) { var u string if opt != nil && opt.Type != "" { u = fmt.Sprintf("repos/%v/%v/git/refs/%v", owner, repo, opt.Type) @@ -92,7 +92,7 @@ func (s *GitService) ListRefs(owner, repo string, opt *ReferenceListOptions) ([] return nil, nil, err } - var rs []Reference + var rs []*Reference resp, err := s.client.Do(req, &rs) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/git_refs_test.go b/vendor/github.com/google/go-github/github/git_refs_test.go index e66bf54a..cc4cd5ae 100644 --- a/vendor/github.com/google/go-github/github/git_refs_test.go +++ b/vendor/github.com/google/go-github/github/git_refs_test.go @@ -89,7 +89,7 @@ func TestGitService_ListRefs(t *testing.T) { t.Errorf("Git.ListRefs returned error: %v", err) } - want := []Reference{ + want := []*Reference{ { Ref: String("refs/heads/branchA"), URL: String("https://api.github.com/repos/o/r/git/refs/heads/branchA"), @@ -130,7 +130,7 @@ func TestGitService_ListRefs_options(t *testing.T) { t.Errorf("Git.ListRefs returned error: %v", err) } - want := []Reference{{Ref: String("r")}} + want := []*Reference{{Ref: String("r")}} if !reflect.DeepEqual(refs, want) { t.Errorf("Git.ListRefs returned %+v, want %+v", refs, want) } diff --git a/vendor/github.com/google/go-github/github/git_tags.go b/vendor/github.com/google/go-github/github/git_tags.go index 7b53f5cc..01b9cb2a 100644 --- a/vendor/github.com/google/go-github/github/git_tags.go +++ b/vendor/github.com/google/go-github/github/git_tags.go @@ -11,12 +11,13 @@ import ( // Tag represents a tag object. type Tag struct { - Tag *string `json:"tag,omitempty"` - SHA *string `json:"sha,omitempty"` - URL *string `json:"url,omitempty"` - Message *string `json:"message,omitempty"` - Tagger *CommitAuthor `json:"tagger,omitempty"` - Object *GitObject `json:"object,omitempty"` + Tag *string `json:"tag,omitempty"` + SHA *string `json:"sha,omitempty"` + URL *string `json:"url,omitempty"` + Message *string `json:"message,omitempty"` + Tagger *CommitAuthor `json:"tagger,omitempty"` + Object *GitObject `json:"object,omitempty"` + Verification *SignatureVerification `json:"verification,omitempty"` } // createTagRequest represents the body of a CreateTag request. This is mostly @@ -40,6 +41,9 @@ func (s *GitService) GetTag(owner string, repo string, sha string) (*Tag, *Respo return nil, nil, err } + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeGitSigningPreview) + tag := new(Tag) resp, err := s.client.Do(req, tag) return tag, resp, err diff --git a/vendor/github.com/google/go-github/github/git_tags_test.go b/vendor/github.com/google/go-github/github/git_tags_test.go index fb41bf38..c44361db 100644 --- a/vendor/github.com/google/go-github/github/git_tags_test.go +++ b/vendor/github.com/google/go-github/github/git_tags_test.go @@ -19,12 +19,12 @@ func TestGitService_GetTag(t *testing.T) { mux.HandleFunc("/repos/o/r/git/tags/s", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") + testHeader(t, r, "Accept", mediaTypeGitSigningPreview) fmt.Fprint(w, `{"tag": "t"}`) }) tag, _, err := client.Git.GetTag("o", "r", "s") - if err != nil { t.Errorf("Git.GetTag returned error: %v", err) } diff --git a/vendor/github.com/google/go-github/github/github.go b/vendor/github.com/google/go-github/github/github.go index 01e573da..5a4afcfe 100644 --- a/vendor/github.com/google/go-github/github/github.go +++ b/vendor/github.com/google/go-github/github/github.go @@ -29,7 +29,7 @@ const ( ) const ( - libraryVersion = "0.1" + libraryVersion = "2" defaultBaseURL = "https://api.github.com/" uploadBaseURL = "https://uploads.github.com/" userAgent = "go-github/" + libraryVersion @@ -39,9 +39,10 @@ const ( headerRateReset = "X-RateLimit-Reset" headerOTP = "X-GitHub-OTP" - mediaTypeV3 = "application/vnd.github.v3+json" - defaultMediaType = "application/octet-stream" - mediaTypeV3SHA = "application/vnd.github.v3.sha" + mediaTypeV3 = "application/vnd.github.v3+json" + defaultMediaType = "application/octet-stream" + mediaTypeV3SHA = "application/vnd.github.v3.sha" + mediaTypeOrgPermissionRepo = "application/vnd.github.v3.repository+json" // Media Type values to access preview APIs @@ -51,16 +52,9 @@ const ( // https://developer.github.com/changes/2014-12-09-new-attributes-for-stars-api/ mediaTypeStarringPreview = "application/vnd.github.v3.star+json" - // https://developer.github.com/changes/2015-06-24-api-enhancements-for-working-with-organization-permissions/ - mediaTypeOrgPermissionPreview = "application/vnd.github.ironman-preview+json" - mediaTypeOrgPermissionRepoPreview = "application/vnd.github.ironman-preview.repository+json" - // https://developer.github.com/changes/2015-11-11-protected-branches-api/ mediaTypeProtectedBranchesPreview = "application/vnd.github.loki-preview+json" - // https://developer.github.com/changes/2016-02-11-issue-locking-api/ - mediaTypeIssueLockingPreview = "application/vnd.github.the-key-preview+json" - // https://help.github.com/enterprise/2.4/admin/guides/migrations/exporting-the-github-com-organization-s-repositories/ mediaTypeMigrationsPreview = "application/vnd.github.wyandotte-preview+json" @@ -72,6 +66,24 @@ const ( // https://developer.github.com/changes/2016-05-12-reactions-api-preview/ mediaTypeReactionsPreview = "application/vnd.github.squirrel-girl-preview" + + // https://developer.github.com/changes/2016-04-01-squash-api-preview/ + mediaTypeSquashPreview = "application/vnd.github.polaris-preview+json" + + // https://developer.github.com/changes/2016-04-04-git-signing-api-preview/ + mediaTypeGitSigningPreview = "application/vnd.github.cryptographer-preview+json" + + // https://developer.github.com/changes/2016-5-27-multiple-assignees/ + mediaTypeMultipleAssigneesPreview = "application/vnd.github.cerberus-preview+json" + + // https://developer.github.com/changes/2016-05-23-timeline-preview-api/ + mediaTypeTimelinePreview = "application/vnd.github.mockingbird-preview+json" + + // https://developer.github.com/changes/2016-06-14-repository-invitations/ + mediaTypeRepositoryInvitationsPreview = "application/vnd.github.swamp-thing-preview+json" + + // https://developer.github.com/changes/2016-04-21-oauth-authorizations-grants-api-preview/ + mediaTypeOAuthGrantAuthorizationsPreview = "application/vnd.github.damage-preview+json" ) // A Client manages communication with the GitHub API. @@ -435,6 +447,10 @@ type ErrorResponse struct { Reason string `json:"reason,omitempty"` CreatedAt *Timestamp `json:"created_at,omitempty"` } `json:"block,omitempty"` + // Most errors will also include a documentation_url field pointing + // to some content that might help you resolve the error, see + // https://developer.github.com/v3/#client-errors + DocumentationURL string `json:"documentation_url,omitempty"` } func (r *ErrorResponse) Error() string { @@ -490,6 +506,9 @@ These are the possible validation error codes: the formatting of a field is invalid already_exists: another resource has the same valid as this field + custom: + some resources return this (e.g. github.User.CreateKey()), additional + information is set in the Message field of the Error GitHub API docs: http://developer.github.com/v3/#client-errors */ @@ -497,6 +516,7 @@ type Error struct { Resource string `json:"resource"` // resource on which the error occurred Field string `json:"field"` // field on which the error occurred Code string `json:"code"` // validation error code + Message string `json:"message"` // Message describing the error. Errors with Code == "custom" will always have this set. } func (e *Error) Error() string { diff --git a/vendor/github.com/google/go-github/github/github_test.go b/vendor/github.com/google/go-github/github/github_test.go index d404a004..39b0766f 100644 --- a/vendor/github.com/google/go-github/github/github_test.go +++ b/vendor/github.com/google/go-github/github/github_test.go @@ -397,7 +397,6 @@ func TestDo_rateLimit(t *testing.T) { req, _ := client.NewRequest("GET", "/", nil) _, err := client.Do(req, nil) - if err != nil { t.Errorf("Do returned unexpected error: %v", err) } @@ -551,7 +550,6 @@ func TestDo_noContent(t *testing.T) { req, _ := client.NewRequest("GET", "/", nil) _, err := client.Do(req, &body) - if err != nil { t.Fatalf("Do returned unexpected error: %v", err) } @@ -630,7 +628,6 @@ func TestCheckResponse_noBody(t *testing.T) { func TestParseBooleanResponse_true(t *testing.T) { result, err := parseBoolResponse(nil) - if err != nil { t.Errorf("parseBoolResponse returned error: %+v", err) } @@ -643,7 +640,6 @@ func TestParseBooleanResponse_true(t *testing.T) { func TestParseBooleanResponse_false(t *testing.T) { v := &ErrorResponse{Response: &http.Response{StatusCode: http.StatusNotFound}} result, err := parseBoolResponse(v) - if err != nil { t.Errorf("parseBoolResponse returned error: %+v", err) } diff --git a/vendor/github.com/google/go-github/github/issues.go b/vendor/github.com/google/go-github/github/issues.go index d380dd36..5d6408d7 100644 --- a/vendor/github.com/google/go-github/github/issues.go +++ b/vendor/github.com/google/go-github/github/issues.go @@ -37,6 +37,7 @@ type Issue struct { PullRequestLinks *PullRequestLinks `json:"pull_request,omitempty"` Repository *Repository `json:"repository,omitempty"` Reactions *Reactions `json:"reactions,omitempty"` + Assignees []*User `json:"assignees,omitempty"` // TextMatches is only populated from search results that request text matches // See: search.go and https://developer.github.com/v3/search/#text-match-metadata @@ -57,6 +58,7 @@ type IssueRequest struct { Assignee *string `json:"assignee,omitempty"` State *string `json:"state,omitempty"` Milestone *int `json:"milestone,omitempty"` + Assignees *[]string `json:"assignees,omitempty"` } // IssueListOptions specifies the optional parameters to the IssuesService.List @@ -102,7 +104,7 @@ type PullRequestLinks struct { // repositories. // // GitHub API docs: http://developer.github.com/v3/issues/#list-issues -func (s *IssuesService) List(all bool, opt *IssueListOptions) ([]Issue, *Response, error) { +func (s *IssuesService) List(all bool, opt *IssueListOptions) ([]*Issue, *Response, error) { var u string if all { u = "issues" @@ -116,12 +118,12 @@ func (s *IssuesService) List(all bool, opt *IssueListOptions) ([]Issue, *Respons // authenticated user. // // GitHub API docs: http://developer.github.com/v3/issues/#list-issues -func (s *IssuesService) ListByOrg(org string, opt *IssueListOptions) ([]Issue, *Response, error) { +func (s *IssuesService) ListByOrg(org string, opt *IssueListOptions) ([]*Issue, *Response, error) { u := fmt.Sprintf("orgs/%v/issues", org) return s.listIssues(u, opt) } -func (s *IssuesService) listIssues(u string, opt *IssueListOptions) ([]Issue, *Response, error) { +func (s *IssuesService) listIssues(u string, opt *IssueListOptions) ([]*Issue, *Response, error) { u, err := addOptions(u, opt) if err != nil { return nil, nil, err @@ -135,7 +137,7 @@ func (s *IssuesService) listIssues(u string, opt *IssueListOptions) ([]Issue, *R // TODO: remove custom Accept header when this API fully launches. req.Header.Set("Accept", mediaTypeReactionsPreview) - issues := new([]Issue) + issues := new([]*Issue) resp, err := s.client.Do(req, issues) if err != nil { return nil, resp, err @@ -187,7 +189,7 @@ type IssueListByRepoOptions struct { // ListByRepo lists the issues for the specified repository. // // GitHub API docs: http://developer.github.com/v3/issues/#list-issues-for-a-repository -func (s *IssuesService) ListByRepo(owner string, repo string, opt *IssueListByRepoOptions) ([]Issue, *Response, error) { +func (s *IssuesService) ListByRepo(owner string, repo string, opt *IssueListByRepoOptions) ([]*Issue, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues", owner, repo) u, err := addOptions(u, opt) if err != nil { @@ -202,7 +204,7 @@ func (s *IssuesService) ListByRepo(owner string, repo string, opt *IssueListByRe // TODO: remove custom Accept header when this API fully launches. req.Header.Set("Accept", mediaTypeReactionsPreview) - issues := new([]Issue) + issues := new([]*Issue) resp, err := s.client.Do(req, issues) if err != nil { return nil, resp, err @@ -243,6 +245,9 @@ func (s *IssuesService) Create(owner string, repo string, issue *IssueRequest) ( return nil, nil, err } + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeMultipleAssigneesPreview) + i := new(Issue) resp, err := s.client.Do(req, i) if err != nil { @@ -262,6 +267,9 @@ func (s *IssuesService) Edit(owner string, repo string, number int, issue *Issue return nil, nil, err } + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeMultipleAssigneesPreview) + i := new(Issue) resp, err := s.client.Do(req, i) if err != nil { @@ -281,9 +289,6 @@ func (s *IssuesService) Lock(owner string, repo string, number int) (*Response, return nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeIssueLockingPreview) - return s.client.Do(req, nil) } @@ -297,8 +302,5 @@ func (s *IssuesService) Unlock(owner string, repo string, number int) (*Response return nil, err } - // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeIssueLockingPreview) - return s.client.Do(req, nil) } diff --git a/vendor/github.com/google/go-github/github/issues_assignees.go b/vendor/github.com/google/go-github/github/issues_assignees.go index 6338c22e..4b7bba2b 100644 --- a/vendor/github.com/google/go-github/github/issues_assignees.go +++ b/vendor/github.com/google/go-github/github/issues_assignees.go @@ -11,7 +11,7 @@ import "fmt" // which issues may be assigned. // // GitHub API docs: http://developer.github.com/v3/issues/assignees/#list-assignees -func (s *IssuesService) ListAssignees(owner string, repo string, opt *ListOptions) ([]User, *Response, error) { +func (s *IssuesService) ListAssignees(owner, repo string, opt *ListOptions) ([]*User, *Response, error) { u := fmt.Sprintf("repos/%v/%v/assignees", owner, repo) u, err := addOptions(u, opt) if err != nil { @@ -22,7 +22,7 @@ func (s *IssuesService) ListAssignees(owner string, repo string, opt *ListOption if err != nil { return nil, nil, err } - assignees := new([]User) + assignees := new([]*User) resp, err := s.client.Do(req, assignees) if err != nil { return nil, resp, err @@ -34,7 +34,7 @@ func (s *IssuesService) ListAssignees(owner string, repo string, opt *ListOption // IsAssignee checks if a user is an assignee for the specified repository. // // GitHub API docs: http://developer.github.com/v3/issues/assignees/#check-assignee -func (s *IssuesService) IsAssignee(owner string, repo string, user string) (bool, *Response, error) { +func (s *IssuesService) IsAssignee(owner, repo, user string) (bool, *Response, error) { u := fmt.Sprintf("repos/%v/%v/assignees/%v", owner, repo, user) req, err := s.client.NewRequest("GET", u, nil) if err != nil { @@ -44,3 +44,45 @@ func (s *IssuesService) IsAssignee(owner string, repo string, user string) (bool assignee, err := parseBoolResponse(err) return assignee, resp, err } + +// AddAssignees adds the provided GitHub users as assignees to the issue. +// +// GitHub API docs: https://developer.github.com/v3/issues/assignees/#add-assignees-to-an-issue +func (s *IssuesService) AddAssignees(owner, repo string, number int, assignees []string) (*Issue, *Response, error) { + users := &struct { + Assignees []string `json:"assignees,omitempty"` + }{Assignees: assignees} + u := fmt.Sprintf("repos/%v/%v/issues/%v/assignees", owner, repo, number) + req, err := s.client.NewRequest("POST", u, users) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeMultipleAssigneesPreview) + + issue := &Issue{} + resp, err := s.client.Do(req, issue) + return issue, resp, err +} + +// RemoveAssignees removes the provided GitHub users as assignees from the issue. +// +// GitHub API docs: https://developer.github.com/v3/issues/assignees/#remove-assignees-from-an-issue +func (s *IssuesService) RemoveAssignees(owner, repo string, number int, assignees []string) (*Issue, *Response, error) { + users := &struct { + Assignees []string `json:"assignees,omitempty"` + }{Assignees: assignees} + u := fmt.Sprintf("repos/%v/%v/issues/%v/assignees", owner, repo, number) + req, err := s.client.NewRequest("DELETE", u, users) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeMultipleAssigneesPreview) + + issue := &Issue{} + resp, err := s.client.Do(req, issue) + return issue, resp, err +} diff --git a/vendor/github.com/google/go-github/github/issues_assignees_test.go b/vendor/github.com/google/go-github/github/issues_assignees_test.go index 63e024d3..2c42d8dd 100644 --- a/vendor/github.com/google/go-github/github/issues_assignees_test.go +++ b/vendor/github.com/google/go-github/github/issues_assignees_test.go @@ -6,6 +6,7 @@ package github import ( + "encoding/json" "fmt" "net/http" "reflect" @@ -25,10 +26,10 @@ func TestIssuesService_ListAssignees(t *testing.T) { opt := &ListOptions{Page: 2} assignees, _, err := client.Issues.ListAssignees("o", "r", opt) if err != nil { - t.Errorf("Issues.List returned error: %v", err) + t.Errorf("Issues.ListAssignees returned error: %v", err) } - want := []User{{ID: Int(1)}} + want := []*User{{ID: Int(1)}} if !reflect.DeepEqual(assignees, want) { t.Errorf("Issues.ListAssignees returned %+v, want %+v", assignees, want) } @@ -96,3 +97,63 @@ func TestIssuesService_IsAssignee_invalidOwner(t *testing.T) { _, _, err := client.Issues.IsAssignee("%", "r", "u") testURLParseError(t, err) } + +func TestIssuesService_AddAssignees(t *testing.T) { + setup() + defer teardown() + + mux.HandleFunc("/repos/o/r/issues/1/assignees", func(w http.ResponseWriter, r *http.Request) { + var assignees struct { + Assignees []string `json:"assignees,omitempty"` + } + json.NewDecoder(r.Body).Decode(&assignees) + + testMethod(t, r, "POST") + testHeader(t, r, "Accept", mediaTypeMultipleAssigneesPreview) + want := []string{"user1", "user2"} + if !reflect.DeepEqual(assignees.Assignees, want) { + t.Errorf("assignees = %+v, want %+v", assignees, want) + } + fmt.Fprint(w, `{"number":1,"assignees":[{"login":"user1"},{"login":"user2"}]}`) + }) + + got, _, err := client.Issues.AddAssignees("o", "r", 1, []string{"user1", "user2"}) + if err != nil { + t.Errorf("Issues.AddAssignees returned error: %v", err) + } + + want := &Issue{Number: Int(1), Assignees: []*User{{Login: String("user1")}, {Login: String("user2")}}} + if !reflect.DeepEqual(got, want) { + t.Errorf("Issues.AddAssignees = %+v, want %+v", got, want) + } +} + +func TestIssuesService_RemoveAssignees(t *testing.T) { + setup() + defer teardown() + + mux.HandleFunc("/repos/o/r/issues/1/assignees", func(w http.ResponseWriter, r *http.Request) { + var assignees struct { + Assignees []string `json:"assignees,omitempty"` + } + json.NewDecoder(r.Body).Decode(&assignees) + + testMethod(t, r, "DELETE") + testHeader(t, r, "Accept", mediaTypeMultipleAssigneesPreview) + want := []string{"user1", "user2"} + if !reflect.DeepEqual(assignees.Assignees, want) { + t.Errorf("assignees = %+v, want %+v", assignees, want) + } + fmt.Fprint(w, `{"number":1,"assignees":[]}`) + }) + + got, _, err := client.Issues.RemoveAssignees("o", "r", 1, []string{"user1", "user2"}) + if err != nil { + t.Errorf("Issues.RemoveAssignees returned error: %v", err) + } + + want := &Issue{Number: Int(1), Assignees: []*User{}} + if !reflect.DeepEqual(got, want) { + t.Errorf("Issues.RemoveAssignees = %+v, want %+v", got, want) + } +} diff --git a/vendor/github.com/google/go-github/github/issues_comments.go b/vendor/github.com/google/go-github/github/issues_comments.go index 6dbc31e1..b24c5aed 100644 --- a/vendor/github.com/google/go-github/github/issues_comments.go +++ b/vendor/github.com/google/go-github/github/issues_comments.go @@ -46,7 +46,7 @@ type IssueListCommentsOptions struct { // number of 0 will return all comments on all issues for the repository. // // GitHub API docs: http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue -func (s *IssuesService) ListComments(owner string, repo string, number int, opt *IssueListCommentsOptions) ([]IssueComment, *Response, error) { +func (s *IssuesService) ListComments(owner string, repo string, number int, opt *IssueListCommentsOptions) ([]*IssueComment, *Response, error) { var u string if number == 0 { u = fmt.Sprintf("repos/%v/%v/issues/comments", owner, repo) @@ -66,7 +66,7 @@ func (s *IssuesService) ListComments(owner string, repo string, number int, opt // TODO: remove custom Accept header when this API fully launches. req.Header.Set("Accept", mediaTypeReactionsPreview) - comments := new([]IssueComment) + comments := new([]*IssueComment) resp, err := s.client.Do(req, comments) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/issues_comments_test.go b/vendor/github.com/google/go-github/github/issues_comments_test.go index 280fbd30..b3a0ec19 100644 --- a/vendor/github.com/google/go-github/github/issues_comments_test.go +++ b/vendor/github.com/google/go-github/github/issues_comments_test.go @@ -41,7 +41,7 @@ func TestIssuesService_ListComments_allIssues(t *testing.T) { t.Errorf("Issues.ListComments returned error: %v", err) } - want := []IssueComment{{ID: Int(1)}} + want := []*IssueComment{{ID: Int(1)}} if !reflect.DeepEqual(comments, want) { t.Errorf("Issues.ListComments returned %+v, want %+v", comments, want) } @@ -62,7 +62,7 @@ func TestIssuesService_ListComments_specificIssue(t *testing.T) { t.Errorf("Issues.ListComments returned error: %v", err) } - want := []IssueComment{{ID: Int(1)}} + want := []*IssueComment{{ID: Int(1)}} if !reflect.DeepEqual(comments, want) { t.Errorf("Issues.ListComments returned %+v, want %+v", comments, want) } diff --git a/vendor/github.com/google/go-github/github/issues_events.go b/vendor/github.com/google/go-github/github/issues_events.go index 9062d4da..71cf61ad 100644 --- a/vendor/github.com/google/go-github/github/issues_events.go +++ b/vendor/github.com/google/go-github/github/issues_events.go @@ -73,7 +73,7 @@ type IssueEvent struct { // ListIssueEvents lists events for the specified issue. // // GitHub API docs: https://developer.github.com/v3/issues/events/#list-events-for-an-issue -func (s *IssuesService) ListIssueEvents(owner, repo string, number int, opt *ListOptions) ([]IssueEvent, *Response, error) { +func (s *IssuesService) ListIssueEvents(owner, repo string, number int, opt *ListOptions) ([]*IssueEvent, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/%v/events", owner, repo, number) u, err := addOptions(u, opt) if err != nil { @@ -85,7 +85,7 @@ func (s *IssuesService) ListIssueEvents(owner, repo string, number int, opt *Lis return nil, nil, err } - var events []IssueEvent + var events []*IssueEvent resp, err := s.client.Do(req, &events) if err != nil { return nil, resp, err @@ -97,7 +97,7 @@ func (s *IssuesService) ListIssueEvents(owner, repo string, number int, opt *Lis // ListRepositoryEvents lists events for the specified repository. // // GitHub API docs: https://developer.github.com/v3/issues/events/#list-events-for-a-repository -func (s *IssuesService) ListRepositoryEvents(owner, repo string, opt *ListOptions) ([]IssueEvent, *Response, error) { +func (s *IssuesService) ListRepositoryEvents(owner, repo string, opt *ListOptions) ([]*IssueEvent, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/events", owner, repo) u, err := addOptions(u, opt) if err != nil { @@ -109,7 +109,7 @@ func (s *IssuesService) ListRepositoryEvents(owner, repo string, opt *ListOption return nil, nil, err } - var events []IssueEvent + var events []*IssueEvent resp, err := s.client.Do(req, &events) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/issues_events_test.go b/vendor/github.com/google/go-github/github/issues_events_test.go index f90b64a7..2250432e 100644 --- a/vendor/github.com/google/go-github/github/issues_events_test.go +++ b/vendor/github.com/google/go-github/github/issues_events_test.go @@ -27,12 +27,11 @@ func TestIssuesService_ListIssueEvents(t *testing.T) { opt := &ListOptions{Page: 1, PerPage: 2} events, _, err := client.Issues.ListIssueEvents("o", "r", 1, opt) - if err != nil { t.Errorf("Issues.ListIssueEvents returned error: %v", err) } - want := []IssueEvent{{ID: Int(1)}} + want := []*IssueEvent{{ID: Int(1)}} if !reflect.DeepEqual(events, want) { t.Errorf("Issues.ListIssueEvents returned %+v, want %+v", events, want) } @@ -53,12 +52,11 @@ func TestIssuesService_ListRepositoryEvents(t *testing.T) { opt := &ListOptions{Page: 1, PerPage: 2} events, _, err := client.Issues.ListRepositoryEvents("o", "r", opt) - if err != nil { t.Errorf("Issues.ListRepositoryEvents returned error: %v", err) } - want := []IssueEvent{{ID: Int(1)}} + want := []*IssueEvent{{ID: Int(1)}} if !reflect.DeepEqual(events, want) { t.Errorf("Issues.ListRepositoryEvents returned %+v, want %+v", events, want) } @@ -74,7 +72,6 @@ func TestIssuesService_GetEvent(t *testing.T) { }) event, _, err := client.Issues.GetEvent("o", "r", 1) - if err != nil { t.Errorf("Issues.GetEvent returned error: %v", err) } diff --git a/vendor/github.com/google/go-github/github/issues_labels.go b/vendor/github.com/google/go-github/github/issues_labels.go index 88f9f3ff..c6545478 100644 --- a/vendor/github.com/google/go-github/github/issues_labels.go +++ b/vendor/github.com/google/go-github/github/issues_labels.go @@ -21,7 +21,7 @@ func (l Label) String() string { // ListLabels lists all labels for a repository. // // GitHub API docs: http://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository -func (s *IssuesService) ListLabels(owner string, repo string, opt *ListOptions) ([]Label, *Response, error) { +func (s *IssuesService) ListLabels(owner string, repo string, opt *ListOptions) ([]*Label, *Response, error) { u := fmt.Sprintf("repos/%v/%v/labels", owner, repo) u, err := addOptions(u, opt) if err != nil { @@ -33,7 +33,7 @@ func (s *IssuesService) ListLabels(owner string, repo string, opt *ListOptions) return nil, nil, err } - labels := new([]Label) + labels := new([]*Label) resp, err := s.client.Do(req, labels) if err != nil { return nil, resp, err @@ -114,7 +114,7 @@ func (s *IssuesService) DeleteLabel(owner string, repo string, name string) (*Re // ListLabelsByIssue lists all labels for an issue. // // GitHub API docs: http://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository -func (s *IssuesService) ListLabelsByIssue(owner string, repo string, number int, opt *ListOptions) ([]Label, *Response, error) { +func (s *IssuesService) ListLabelsByIssue(owner string, repo string, number int, opt *ListOptions) ([]*Label, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number) u, err := addOptions(u, opt) if err != nil { @@ -126,7 +126,7 @@ func (s *IssuesService) ListLabelsByIssue(owner string, repo string, number int, return nil, nil, err } - labels := new([]Label) + labels := new([]*Label) resp, err := s.client.Do(req, labels) if err != nil { return nil, resp, err @@ -138,14 +138,14 @@ func (s *IssuesService) ListLabelsByIssue(owner string, repo string, number int, // AddLabelsToIssue adds labels to an issue. // // GitHub API docs: http://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository -func (s *IssuesService) AddLabelsToIssue(owner string, repo string, number int, labels []string) ([]Label, *Response, error) { +func (s *IssuesService) AddLabelsToIssue(owner string, repo string, number int, labels []string) ([]*Label, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number) req, err := s.client.NewRequest("POST", u, labels) if err != nil { return nil, nil, err } - l := new([]Label) + l := new([]*Label) resp, err := s.client.Do(req, l) if err != nil { return nil, resp, err @@ -169,14 +169,14 @@ func (s *IssuesService) RemoveLabelForIssue(owner string, repo string, number in // ReplaceLabelsForIssue replaces all labels for an issue. // // GitHub API docs: http://developer.github.com/v3/issues/labels/#replace-all-labels-for-an-issue -func (s *IssuesService) ReplaceLabelsForIssue(owner string, repo string, number int, labels []string) ([]Label, *Response, error) { +func (s *IssuesService) ReplaceLabelsForIssue(owner string, repo string, number int, labels []string) ([]*Label, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number) req, err := s.client.NewRequest("PUT", u, labels) if err != nil { return nil, nil, err } - l := new([]Label) + l := new([]*Label) resp, err := s.client.Do(req, l) if err != nil { return nil, resp, err @@ -200,7 +200,7 @@ func (s *IssuesService) RemoveLabelsForIssue(owner string, repo string, number i // ListLabelsForMilestone lists labels for every issue in a milestone. // // GitHub API docs: http://developer.github.com/v3/issues/labels/#get-labels-for-every-issue-in-a-milestone -func (s *IssuesService) ListLabelsForMilestone(owner string, repo string, number int, opt *ListOptions) ([]Label, *Response, error) { +func (s *IssuesService) ListLabelsForMilestone(owner string, repo string, number int, opt *ListOptions) ([]*Label, *Response, error) { u := fmt.Sprintf("repos/%v/%v/milestones/%d/labels", owner, repo, number) u, err := addOptions(u, opt) if err != nil { @@ -212,7 +212,7 @@ func (s *IssuesService) ListLabelsForMilestone(owner string, repo string, number return nil, nil, err } - labels := new([]Label) + labels := new([]*Label) resp, err := s.client.Do(req, labels) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/issues_labels_test.go b/vendor/github.com/google/go-github/github/issues_labels_test.go index 2243eb0e..e6ae59b4 100644 --- a/vendor/github.com/google/go-github/github/issues_labels_test.go +++ b/vendor/github.com/google/go-github/github/issues_labels_test.go @@ -29,7 +29,7 @@ func TestIssuesService_ListLabels(t *testing.T) { t.Errorf("Issues.ListLabels returned error: %v", err) } - want := []Label{{Name: String("a")}, {Name: String("b")}} + want := []*Label{{Name: String("a")}, {Name: String("b")}} if !reflect.DeepEqual(labels, want) { t.Errorf("Issues.ListLabels returned %+v, want %+v", labels, want) } @@ -168,7 +168,7 @@ func TestIssuesService_ListLabelsByIssue(t *testing.T) { t.Errorf("Issues.ListLabelsByIssue returned error: %v", err) } - want := []Label{{Name: String("a")}, {Name: String("b")}} + want := []*Label{{Name: String("a")}, {Name: String("b")}} if !reflect.DeepEqual(labels, want) { t.Errorf("Issues.ListLabelsByIssue returned %+v, want %+v", labels, want) } @@ -202,7 +202,7 @@ func TestIssuesService_AddLabelsToIssue(t *testing.T) { t.Errorf("Issues.AddLabelsToIssue returned error: %v", err) } - want := []Label{{URL: String("u")}} + want := []*Label{{URL: String("u")}} if !reflect.DeepEqual(labels, want) { t.Errorf("Issues.AddLabelsToIssue returned %+v, want %+v", labels, want) } @@ -255,7 +255,7 @@ func TestIssuesService_ReplaceLabelsForIssue(t *testing.T) { t.Errorf("Issues.ReplaceLabelsForIssue returned error: %v", err) } - want := []Label{{URL: String("u")}} + want := []*Label{{URL: String("u")}} if !reflect.DeepEqual(labels, want) { t.Errorf("Issues.ReplaceLabelsForIssue returned %+v, want %+v", labels, want) } @@ -301,7 +301,7 @@ func TestIssuesService_ListLabelsForMilestone(t *testing.T) { t.Errorf("Issues.ListLabelsForMilestone returned error: %v", err) } - want := []Label{{Name: String("a")}, {Name: String("b")}} + want := []*Label{{Name: String("a")}, {Name: String("b")}} if !reflect.DeepEqual(labels, want) { t.Errorf("Issues.ListLabelsForMilestone returned %+v, want %+v", labels, want) } diff --git a/vendor/github.com/google/go-github/github/issues_milestones.go b/vendor/github.com/google/go-github/github/issues_milestones.go index cc07cd7b..b7621acf 100644 --- a/vendor/github.com/google/go-github/github/issues_milestones.go +++ b/vendor/github.com/google/go-github/github/issues_milestones.go @@ -47,12 +47,14 @@ type MilestoneListOptions struct { // Direction in which to sort milestones. Possible values are: asc, desc. // Default is "asc". Direction string `url:"direction,omitempty"` + + ListOptions } // ListMilestones lists all milestones for a repository. // // GitHub API docs: https://developer.github.com/v3/issues/milestones/#list-milestones-for-a-repository -func (s *IssuesService) ListMilestones(owner string, repo string, opt *MilestoneListOptions) ([]Milestone, *Response, error) { +func (s *IssuesService) ListMilestones(owner string, repo string, opt *MilestoneListOptions) ([]*Milestone, *Response, error) { u := fmt.Sprintf("repos/%v/%v/milestones", owner, repo) u, err := addOptions(u, opt) if err != nil { @@ -64,7 +66,7 @@ func (s *IssuesService) ListMilestones(owner string, repo string, opt *Milestone return nil, nil, err } - milestones := new([]Milestone) + milestones := new([]*Milestone) resp, err := s.client.Do(req, milestones) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/issues_milestones_test.go b/vendor/github.com/google/go-github/github/issues_milestones_test.go index 817fffed..11bf4d39 100644 --- a/vendor/github.com/google/go-github/github/issues_milestones_test.go +++ b/vendor/github.com/google/go-github/github/issues_milestones_test.go @@ -23,17 +23,18 @@ func TestIssuesService_ListMilestones(t *testing.T) { "state": "closed", "sort": "due_date", "direction": "asc", + "page": "2", }) fmt.Fprint(w, `[{"number":1}]`) }) - opt := &MilestoneListOptions{"closed", "due_date", "asc"} + opt := &MilestoneListOptions{"closed", "due_date", "asc", ListOptions{Page: 2}} milestones, _, err := client.Issues.ListMilestones("o", "r", opt) if err != nil { t.Errorf("IssuesService.ListMilestones returned error: %v", err) } - want := []Milestone{{Number: Int(1)}} + want := []*Milestone{{Number: Int(1)}} if !reflect.DeepEqual(milestones, want) { t.Errorf("IssuesService.ListMilestones returned %+v, want %+v", milestones, want) } diff --git a/vendor/github.com/google/go-github/github/issues_test.go b/vendor/github.com/google/go-github/github/issues_test.go index 657e0607..3b436def 100644 --- a/vendor/github.com/google/go-github/github/issues_test.go +++ b/vendor/github.com/google/go-github/github/issues_test.go @@ -40,12 +40,11 @@ func TestIssuesService_List_all(t *testing.T) { ListOptions{Page: 1, PerPage: 2}, } issues, _, err := client.Issues.List(true, opt) - if err != nil { t.Errorf("Issues.List returned error: %v", err) } - want := []Issue{{Number: Int(1)}} + want := []*Issue{{Number: Int(1)}} if !reflect.DeepEqual(issues, want) { t.Errorf("Issues.List returned %+v, want %+v", issues, want) } @@ -66,7 +65,7 @@ func TestIssuesService_List_owned(t *testing.T) { t.Errorf("Issues.List returned error: %v", err) } - want := []Issue{{Number: Int(1)}} + want := []*Issue{{Number: Int(1)}} if !reflect.DeepEqual(issues, want) { t.Errorf("Issues.List returned %+v, want %+v", issues, want) } @@ -87,7 +86,7 @@ func TestIssuesService_ListByOrg(t *testing.T) { t.Errorf("Issues.ListByOrg returned error: %v", err) } - want := []Issue{{Number: Int(1)}} + want := []*Issue{{Number: Int(1)}} if !reflect.DeepEqual(issues, want) { t.Errorf("Issues.List returned %+v, want %+v", issues, want) } @@ -129,7 +128,7 @@ func TestIssuesService_ListByRepo(t *testing.T) { t.Errorf("Issues.ListByOrg returned error: %v", err) } - want := []Issue{{Number: Int(1)}} + want := []*Issue{{Number: Int(1)}} if !reflect.DeepEqual(issues, want) { t.Errorf("Issues.List returned %+v, want %+v", issues, want) } @@ -189,6 +188,7 @@ func TestIssuesService_Create(t *testing.T) { json.NewDecoder(r.Body).Decode(v) testMethod(t, r, "POST") + testHeader(t, r, "Accept", mediaTypeMultipleAssigneesPreview) if !reflect.DeepEqual(v, input) { t.Errorf("Request body = %+v, want %+v", v, input) } @@ -223,6 +223,7 @@ func TestIssuesService_Edit(t *testing.T) { json.NewDecoder(r.Body).Decode(v) testMethod(t, r, "PATCH") + testHeader(t, r, "Accept", mediaTypeMultipleAssigneesPreview) if !reflect.DeepEqual(v, input) { t.Errorf("Request body = %+v, want %+v", v, input) } @@ -252,7 +253,6 @@ func TestIssuesService_Lock(t *testing.T) { mux.HandleFunc("/repos/o/r/issues/1/lock", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") - testHeader(t, r, "Accept", mediaTypeIssueLockingPreview) w.WriteHeader(http.StatusNoContent) }) @@ -268,7 +268,6 @@ func TestIssuesService_Unlock(t *testing.T) { mux.HandleFunc("/repos/o/r/issues/1/lock", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") - testHeader(t, r, "Accept", mediaTypeIssueLockingPreview) w.WriteHeader(http.StatusNoContent) }) diff --git a/vendor/github.com/google/go-github/github/issues_timeline.go b/vendor/github.com/google/go-github/github/issues_timeline.go new file mode 100644 index 00000000..d20eef8f --- /dev/null +++ b/vendor/github.com/google/go-github/github/issues_timeline.go @@ -0,0 +1,148 @@ +// Copyright 2016 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "fmt" + "time" +) + +// Timeline represents an event that occurred around an Issue or Pull Request. +// +// It is similar to an IssueEvent but may contain more information. +// GitHub API docs: https://developer.github.com/v3/issues/timeline/ +type Timeline struct { + ID *int `json:"id,omitempty"` + URL *string `json:"url,omitempty"` + CommitURL *string `json:"commit_url,omitempty"` + + // The User object that generated the event. + Actor *User `json:"actor,omitempty"` + + // Event identifies the actual type of Event that occurred. Possible values + // are: + // + // assigned + // The issue was assigned to the assignee. + // + // closed + // The issue was closed by the actor. When the commit_id is present, it + // identifies the commit that closed the issue using "closes / fixes #NN" + // syntax. + // + // commented + // A comment was added to the issue. + // + // committed + // A commit was added to the pull request's 'HEAD' branch. Only provided + // for pull requests. + // + // cross-referenced + // The issue was referenced from another issue. The 'source' attribute + // contains the 'id', 'actor', and 'url' of the reference's source. + // + // demilestoned + // The issue was removed from a milestone. + // + // head_ref_deleted + // The pull request's branch was deleted. + // + // head_ref_restored + // The pull request's branch was restored. + // + // labeled + // A label was added to the issue. + // + // locked + // The issue was locked by the actor. + // + // mentioned + // The actor was @mentioned in an issue body. + // + // merged + // The issue was merged by the actor. The 'commit_id' attribute is the + // SHA1 of the HEAD commit that was merged. + // + // milestoned + // The issue was added to a milestone. + // + // referenced + // The issue was referenced from a commit message. The 'commit_id' + // attribute is the commit SHA1 of where that happened. + // + // renamed + // The issue title was changed. + // + // reopened + // The issue was reopened by the actor. + // + // subscribed + // The actor subscribed to receive notifications for an issue. + // + // unassigned + // The assignee was unassigned from the issue. + // + // unlabeled + // A label was removed from the issue. + // + // unlocked + // The issue was unlocked by the actor. + // + // unsubscribed + // The actor unsubscribed to stop receiving notifications for an issue. + // + Event *string `json:"event,omitempty"` + + // The string SHA of a commit that referenced this Issue or Pull Request. + CommitID *string `json:"commit_id,omitempty"` + // The timestamp indicating when the event occurred. + CreatedAt *time.Time `json:"created_at,omitempty"` + // The Label object including `name` and `color` attributes. Only provided for + // 'labeled' and 'unlabeled' events. + Label *Label `json:"label,omitempty"` + // The User object which was assigned to (or unassigned from) this Issue or + // Pull Request. Only provided for 'assigned' and 'unassigned' events. + Assignee *User `json:"assignee,omitempty"` + // The Milestone object including a 'title' attribute. + // Only provided for 'milestoned' and 'demilestoned' events. + Milestone *Milestone `json:"milestone,omitempty"` + // The 'id', 'actor', and 'url' for the source of a reference from another issue. + // Only provided for 'cross-referenced' events. + Source *Source `json:"source,omitempty"` + // An object containing rename details including 'from' and 'to' attributes. + // Only provided for 'renamed' events. + Rename *Rename `json:"rename,omitempty"` +} + +// Source represents a reference's source. +type Source struct { + ID *int `json:"id,omitempty"` + URL *string `json:"url,omitempty"` + Actor *User `json:"actor,omitempty"` +} + +// ListIssueTimeline lists events for the specified issue. +// +// GitHub API docs: https://developer.github.com/v3/issues/timeline/#list-events-for-an-issue +func (s *IssuesService) ListIssueTimeline(owner, repo string, number int, opt *ListOptions) ([]*Timeline, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/issues/%v/timeline", owner, repo, number) + u, err := addOptions(u, opt) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeTimelinePreview) + + var events []*Timeline + resp, err := s.client.Do(req, &events) + return events, resp, err +} diff --git a/vendor/github.com/google/go-github/github/issues_timeline_test.go b/vendor/github.com/google/go-github/github/issues_timeline_test.go new file mode 100644 index 00000000..fb67fd6b --- /dev/null +++ b/vendor/github.com/google/go-github/github/issues_timeline_test.go @@ -0,0 +1,39 @@ +// Copyright 2016 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "fmt" + "net/http" + "reflect" + "testing" +) + +func TestIssuesService_ListIssueTimeline(t *testing.T) { + setup() + defer teardown() + + mux.HandleFunc("/repos/o/r/issues/1/timeline", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testHeader(t, r, "Accept", mediaTypeTimelinePreview) + testFormValues(t, r, values{ + "page": "1", + "per_page": "2", + }) + fmt.Fprint(w, `[{"id":1}]`) + }) + + opt := &ListOptions{Page: 1, PerPage: 2} + events, _, err := client.Issues.ListIssueTimeline("o", "r", 1, opt) + if err != nil { + t.Errorf("Issues.ListIssueTimeline returned error: %v", err) + } + + want := []*Timeline{{ID: Int(1)}} + if !reflect.DeepEqual(events, want) { + t.Errorf("Issues.ListIssueTimeline = %+v, want %+v", events, want) + } +} diff --git a/vendor/github.com/google/go-github/github/licenses.go b/vendor/github.com/google/go-github/github/licenses.go index fb2fb5af..93f69323 100644 --- a/vendor/github.com/google/go-github/github/licenses.go +++ b/vendor/github.com/google/go-github/github/licenses.go @@ -39,7 +39,7 @@ func (l License) String() string { // List popular open source licenses. // // GitHub API docs: https://developer.github.com/v3/licenses/#list-all-licenses -func (s *LicensesService) List() ([]License, *Response, error) { +func (s *LicensesService) List() ([]*License, *Response, error) { req, err := s.client.NewRequest("GET", "licenses", nil) if err != nil { return nil, nil, err @@ -48,7 +48,7 @@ func (s *LicensesService) List() ([]License, *Response, error) { // TODO: remove custom Accept header when this API fully launches req.Header.Set("Accept", mediaTypeLicensesPreview) - licenses := new([]License) + licenses := new([]*License) resp, err := s.client.Do(req, licenses) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/licenses_test.go b/vendor/github.com/google/go-github/github/licenses_test.go index dfecfebb..2319bb46 100644 --- a/vendor/github.com/google/go-github/github/licenses_test.go +++ b/vendor/github.com/google/go-github/github/licenses_test.go @@ -27,7 +27,7 @@ func TestLicensesService_List(t *testing.T) { t.Errorf("Licenses.List returned error: %v", err) } - want := []License{{ + want := []*License{{ Key: String("mit"), Name: String("MIT"), URL: String("https://api.github.com/licenses/mit"), diff --git a/vendor/github.com/google/go-github/github/messages.go b/vendor/github.com/google/go-github/github/messages.go new file mode 100644 index 00000000..9f0aba90 --- /dev/null +++ b/vendor/github.com/google/go-github/github/messages.go @@ -0,0 +1,119 @@ +// Copyright 2016 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This file provides functions for validating payloads from GitHub Webhooks. +// GitHub docs: https://developer.github.com/webhooks/securing/#validating-payloads-from-github + +package github + +import ( + "crypto/hmac" + "crypto/sha1" + "crypto/sha256" + "crypto/sha512" + "encoding/hex" + "errors" + "fmt" + "hash" + "io/ioutil" + "net/http" + "strings" +) + +const ( + // sha1Prefix is the prefix used by GitHub before the HMAC hexdigest. + sha1Prefix = "sha1" + // sha256Prefix and sha512Prefix are provided for future compatibility. + sha256Prefix = "sha256" + sha512Prefix = "sha512" + // signatureHeader is the GitHub header key used to pass the HMAC hexdigest. + signatureHeader = "X-Hub-Signature" +) + +// genMAC generates the HMAC signature for a message provided the secret key +// and hashFunc. +func genMAC(message, key []byte, hashFunc func() hash.Hash) []byte { + mac := hmac.New(hashFunc, key) + mac.Write(message) + return mac.Sum(nil) +} + +// checkMAC reports whether messageMAC is a valid HMAC tag for message. +func checkMAC(message, messageMAC, key []byte, hashFunc func() hash.Hash) bool { + expectedMAC := genMAC(message, key, hashFunc) + return hmac.Equal(messageMAC, expectedMAC) +} + +// messageMAC returns the hex-decoded HMAC tag from the signature and its +// corresponding hash function. +func messageMAC(signature string) ([]byte, func() hash.Hash, error) { + if signature == "" { + return nil, nil, errors.New("missing signature") + } + sigParts := strings.SplitN(signature, "=", 2) + if len(sigParts) != 2 { + return nil, nil, fmt.Errorf("error parsing signature %q", signature) + } + + var hashFunc func() hash.Hash + switch sigParts[0] { + case sha1Prefix: + hashFunc = sha1.New + case sha256Prefix: + hashFunc = sha256.New + case sha512Prefix: + hashFunc = sha512.New + default: + return nil, nil, fmt.Errorf("unknown hash type prefix: %q", sigParts[0]) + } + + buf, err := hex.DecodeString(sigParts[1]) + if err != nil { + return nil, nil, fmt.Errorf("error decoding signature %q: %v", signature, err) + } + return buf, hashFunc, nil +} + +// ValidatePayload validates an incoming GitHub Webhook event request +// and returns the (JSON) payload. +// secretKey is the GitHub Webhook secret message. +// +// Example usage: +// +// func (s *GitHubEventMonitor) ServeHTTP(w http.ResponseWriter, r *http.Request) { +// payload, err := github.ValidatePayload(r, s.webhookSecretKey) +// if err != nil { ... } +// // Process payload... +// } +// +func ValidatePayload(r *http.Request, secretKey []byte) (payload []byte, err error) { + payload, err = ioutil.ReadAll(r.Body) + if err != nil { + return nil, err + } + + sig := r.Header.Get(signatureHeader) + if err := validateSignature(sig, payload, secretKey); err != nil { + return nil, err + } + return payload, nil +} + +// validateSignature validates the signature for the given payload. +// signature is the GitHub hash signature delivered in the X-Hub-Signature header. +// payload is the JSON payload sent by GitHub Webhooks. +// secretKey is the GitHub Webhook secret message. +// +// GitHub docs: https://developer.github.com/webhooks/securing/#validating-payloads-from-github +func validateSignature(signature string, payload, secretKey []byte) error { + messageMAC, hashFunc, err := messageMAC(signature) + if err != nil { + return err + } + if !checkMAC(payload, messageMAC, secretKey, hashFunc) { + return errors.New("payload signature check failed") + } + return nil +} diff --git a/vendor/github.com/google/go-github/github/messages_test.go b/vendor/github.com/google/go-github/github/messages_test.go new file mode 100644 index 00000000..5373b6a5 --- /dev/null +++ b/vendor/github.com/google/go-github/github/messages_test.go @@ -0,0 +1,81 @@ +// Copyright 2016 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "bytes" + "net/http" + "testing" +) + +func TestValidatePayload(t *testing.T) { + const defaultBody = `{"yo":true}` // All tests below use the default request body and signature. + const defaultSignature = "sha1=126f2c800419c60137ce748d7672e77b65cf16d6" + secretKey := []byte("0123456789abcdef") + tests := []struct { + signature string + eventID string + event string + wantEventID string + wantEvent string + wantPayload string + }{ + // The following tests generate expected errors: + {}, // Missing signature + {signature: "yo"}, // Missing signature prefix + {signature: "sha1=yo"}, // Signature not hex string + {signature: "sha1=012345"}, // Invalid signature + // The following tests expect err=nil: + { + signature: defaultSignature, + eventID: "dead-beef", + event: "ping", + wantEventID: "dead-beef", + wantEvent: "ping", + wantPayload: defaultBody, + }, + { + signature: defaultSignature, + event: "ping", + wantEvent: "ping", + wantPayload: defaultBody, + }, + { + signature: "sha256=b1f8020f5b4cd42042f807dd939015c4a418bc1ff7f604dd55b0a19b5d953d9b", + event: "ping", + wantEvent: "ping", + wantPayload: defaultBody, + }, + { + signature: "sha512=8456767023c1195682e182a23b3f5d19150ecea598fde8cb85918f7281b16079471b1329f92b912c4d8bd7455cb159777db8f29608b20c7c87323ba65ae62e1f", + event: "ping", + wantEvent: "ping", + wantPayload: defaultBody, + }, + } + + for _, test := range tests { + buf := bytes.NewBufferString(defaultBody) + req, err := http.NewRequest("GET", "http://localhost/event", buf) + if err != nil { + t.Fatalf("NewRequest: %v", err) + } + if test.signature != "" { + req.Header.Set(signatureHeader, test.signature) + } + + got, err := ValidatePayload(req, secretKey) + if err != nil { + if test.wantPayload != "" { + t.Errorf("ValidatePayload(%#v): err = %v, want nil", test, err) + } + continue + } + if string(got) != test.wantPayload { + t.Errorf("ValidatePayload = %q, want %q", got, test.wantPayload) + } + } +} diff --git a/vendor/github.com/google/go-github/github/migrations_source_import.go b/vendor/github.com/google/go-github/github/migrations_source_import.go index 4861698c..6ed4acfb 100644 --- a/vendor/github.com/google/go-github/github/migrations_source_import.go +++ b/vendor/github.com/google/go-github/github/migrations_source_import.go @@ -220,7 +220,7 @@ func (s *MigrationService) UpdateImport(owner, repo string, in *Import) (*Import // information. // // GitHub API docs: https://developer.github.com/v3/migration/source_imports/#get-commit-authors -func (s *MigrationService) CommitAuthors(owner, repo string) ([]SourceImportAuthor, *Response, error) { +func (s *MigrationService) CommitAuthors(owner, repo string) ([]*SourceImportAuthor, *Response, error) { u := fmt.Sprintf("repos/%v/%v/import/authors", owner, repo) req, err := s.client.NewRequest("GET", u, nil) if err != nil { @@ -230,7 +230,7 @@ func (s *MigrationService) CommitAuthors(owner, repo string) ([]SourceImportAuth // TODO: remove custom Accept header when this API fully launches req.Header.Set("Accept", mediaTypeImportPreview) - authors := new([]SourceImportAuthor) + authors := new([]*SourceImportAuthor) resp, err := s.client.Do(req, authors) if err != nil { return nil, resp, err @@ -290,7 +290,7 @@ func (s *MigrationService) SetLFSPreference(owner, repo string, in *Import) (*Im // LargeFiles lists files larger than 100MB found during the import. // // GitHub API docs: https://developer.github.com/v3/migration/source_imports/#get-large-files -func (s *MigrationService) LargeFiles(owner, repo string) ([]LargeFile, *Response, error) { +func (s *MigrationService) LargeFiles(owner, repo string) ([]*LargeFile, *Response, error) { u := fmt.Sprintf("repos/%v/%v/import/large_files", owner, repo) req, err := s.client.NewRequest("GET", u, nil) if err != nil { @@ -300,7 +300,7 @@ func (s *MigrationService) LargeFiles(owner, repo string) ([]LargeFile, *Respons // TODO: remove custom Accept header when this API fully launches req.Header.Set("Accept", mediaTypeImportPreview) - files := new([]LargeFile) + files := new([]*LargeFile) resp, err := s.client.Do(req, files) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/migrations_source_import_test.go b/vendor/github.com/google/go-github/github/migrations_source_import_test.go index 1166197a..4995b597 100644 --- a/vendor/github.com/google/go-github/github/migrations_source_import_test.go +++ b/vendor/github.com/google/go-github/github/migrations_source_import_test.go @@ -117,7 +117,7 @@ func TestMigrationService_CommitAuthors(t *testing.T) { if err != nil { t.Errorf("CommitAuthors returned error: %v", err) } - want := []SourceImportAuthor{ + want := []*SourceImportAuthor{ {ID: Int(1), Name: String("a")}, {ID: Int(2), Name: String("b")}, } @@ -199,7 +199,7 @@ func TestMigrationService_LargeFiles(t *testing.T) { if err != nil { t.Errorf("LargeFiles returned error: %v", err) } - want := []LargeFile{ + want := []*LargeFile{ {OID: String("a")}, {OID: String("b")}, } diff --git a/vendor/github.com/google/go-github/github/misc.go b/vendor/github.com/google/go-github/github/misc.go index 66e7f523..8576a4cd 100644 --- a/vendor/github.com/google/go-github/github/misc.go +++ b/vendor/github.com/google/go-github/github/misc.go @@ -180,14 +180,14 @@ func (s *ServiceHook) String() string { // ListServiceHooks lists all of the available service hooks. // // GitHub API docs: https://developer.github.com/webhooks/#services -func (c *Client) ListServiceHooks() ([]ServiceHook, *Response, error) { +func (c *Client) ListServiceHooks() ([]*ServiceHook, *Response, error) { u := "hooks" req, err := c.NewRequest("GET", u, nil) if err != nil { return nil, nil, err } - hooks := new([]ServiceHook) + hooks := new([]*ServiceHook) resp, err := c.Do(req, hooks) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/misc_test.go b/vendor/github.com/google/go-github/github/misc_test.go index 16c55126..afced702 100644 --- a/vendor/github.com/google/go-github/github/misc_test.go +++ b/vendor/github.com/google/go-github/github/misc_test.go @@ -46,20 +46,6 @@ func TestMarkdown(t *testing.T) { } } -func ExampleClient_Markdown() { - client := NewClient(nil) - - input := "# heading #\n\nLink to issue #1" - opt := &MarkdownOptions{Mode: "gfm", Context: "google/go-github"} - - output, _, err := client.Markdown(input, opt) - if err != nil { - fmt.Println(err) - } - - fmt.Println(output) -} - func TestListEmojis(t *testing.T) { setup() defer teardown() @@ -172,7 +158,7 @@ func TestRepositoriesService_ListServiceHooks(t *testing.T) { t.Errorf("Repositories.ListHooks returned error: %v", err) } - want := []ServiceHook{{ + want := []*ServiceHook{{ Name: String("n"), Events: []string{"e"}, SupportedEvents: []string{"s"}, diff --git a/vendor/github.com/google/go-github/github/orgs.go b/vendor/github.com/google/go-github/github/orgs.go index 6018a3ae..c71be224 100644 --- a/vendor/github.com/google/go-github/github/orgs.go +++ b/vendor/github.com/google/go-github/github/orgs.go @@ -73,6 +73,8 @@ func (p Plan) String() string { type OrganizationsListOptions struct { // Since filters Organizations by ID. Since int `url:"since,omitempty"` + + ListOptions } // ListAll lists all organizations, in the order that they were created on GitHub. @@ -82,7 +84,7 @@ type OrganizationsListOptions struct { // as the opts.Since parameter for the next call. // // GitHub API docs: https://developer.github.com/v3/orgs/#list-all-organizations -func (s *OrganizationsService) ListAll(opt *OrganizationsListOptions) ([]Organization, *Response, error) { +func (s *OrganizationsService) ListAll(opt *OrganizationsListOptions) ([]*Organization, *Response, error) { u, err := addOptions("organizations", opt) if err != nil { return nil, nil, err @@ -93,7 +95,7 @@ func (s *OrganizationsService) ListAll(opt *OrganizationsListOptions) ([]Organiz return nil, nil, err } - orgs := []Organization{} + orgs := []*Organization{} resp, err := s.client.Do(req, &orgs) if err != nil { return nil, resp, err @@ -105,7 +107,7 @@ func (s *OrganizationsService) ListAll(opt *OrganizationsListOptions) ([]Organiz // organizations for the authenticated user. // // GitHub API docs: http://developer.github.com/v3/orgs/#list-user-organizations -func (s *OrganizationsService) List(user string, opt *ListOptions) ([]Organization, *Response, error) { +func (s *OrganizationsService) List(user string, opt *ListOptions) ([]*Organization, *Response, error) { var u string if user != "" { u = fmt.Sprintf("users/%v/orgs", user) @@ -122,7 +124,7 @@ func (s *OrganizationsService) List(user string, opt *ListOptions) ([]Organizati return nil, nil, err } - orgs := new([]Organization) + orgs := new([]*Organization) resp, err := s.client.Do(req, orgs) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/orgs_hooks.go b/vendor/github.com/google/go-github/github/orgs_hooks.go index 3e7ad40f..95b83229 100644 --- a/vendor/github.com/google/go-github/github/orgs_hooks.go +++ b/vendor/github.com/google/go-github/github/orgs_hooks.go @@ -10,7 +10,7 @@ import "fmt" // ListHooks lists all Hooks for the specified organization. // // GitHub API docs: https://developer.github.com/v3/orgs/hooks/#list-hooks -func (s *OrganizationsService) ListHooks(org string, opt *ListOptions) ([]Hook, *Response, error) { +func (s *OrganizationsService) ListHooks(org string, opt *ListOptions) ([]*Hook, *Response, error) { u := fmt.Sprintf("orgs/%v/hooks", org) u, err := addOptions(u, opt) if err != nil { @@ -22,7 +22,7 @@ func (s *OrganizationsService) ListHooks(org string, opt *ListOptions) ([]Hook, return nil, nil, err } - hooks := new([]Hook) + hooks := new([]*Hook) resp, err := s.client.Do(req, hooks) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/orgs_hooks_test.go b/vendor/github.com/google/go-github/github/orgs_hooks_test.go index 1ebc07d5..b4c3af77 100644 --- a/vendor/github.com/google/go-github/github/orgs_hooks_test.go +++ b/vendor/github.com/google/go-github/github/orgs_hooks_test.go @@ -30,7 +30,7 @@ func TestOrganizationsService_ListHooks(t *testing.T) { t.Errorf("Organizations.ListHooks returned error: %v", err) } - want := []Hook{{ID: Int(1)}, {ID: Int(2)}} + want := []*Hook{{ID: Int(1)}, {ID: Int(2)}} if !reflect.DeepEqual(hooks, want) { t.Errorf("Organizations.ListHooks returned %+v, want %+v", hooks, want) } diff --git a/vendor/github.com/google/go-github/github/orgs_members.go b/vendor/github.com/google/go-github/github/orgs_members.go index 01a9ba9b..80454ada 100644 --- a/vendor/github.com/google/go-github/github/orgs_members.go +++ b/vendor/github.com/google/go-github/github/orgs_members.go @@ -69,7 +69,7 @@ type ListMembersOptions struct { // public members, otherwise it will only return public members. // // GitHub API docs: http://developer.github.com/v3/orgs/members/#members-list -func (s *OrganizationsService) ListMembers(org string, opt *ListMembersOptions) ([]User, *Response, error) { +func (s *OrganizationsService) ListMembers(org string, opt *ListMembersOptions) ([]*User, *Response, error) { var u string if opt != nil && opt.PublicOnly { u = fmt.Sprintf("orgs/%v/public_members", org) @@ -86,11 +86,7 @@ func (s *OrganizationsService) ListMembers(org string, opt *ListMembersOptions) return nil, nil, err } - if opt != nil && opt.Role != "" { - req.Header.Set("Accept", mediaTypeOrgPermissionPreview) - } - - members := new([]User) + members := new([]*User) resp, err := s.client.Do(req, members) if err != nil { return nil, resp, err @@ -182,7 +178,7 @@ type ListOrgMembershipsOptions struct { // ListOrgMemberships lists the organization memberships for the authenticated user. // // GitHub API docs: https://developer.github.com/v3/orgs/members/#list-your-organization-memberships -func (s *OrganizationsService) ListOrgMemberships(opt *ListOrgMembershipsOptions) ([]Membership, *Response, error) { +func (s *OrganizationsService) ListOrgMemberships(opt *ListOrgMembershipsOptions) ([]*Membership, *Response, error) { u := "user/memberships/orgs" u, err := addOptions(u, opt) if err != nil { @@ -194,7 +190,7 @@ func (s *OrganizationsService) ListOrgMemberships(opt *ListOrgMembershipsOptions return nil, nil, err } - var memberships []Membership + var memberships []*Membership resp, err := s.client.Do(req, &memberships) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/orgs_members_test.go b/vendor/github.com/google/go-github/github/orgs_members_test.go index 6613efe1..f95e5be6 100644 --- a/vendor/github.com/google/go-github/github/orgs_members_test.go +++ b/vendor/github.com/google/go-github/github/orgs_members_test.go @@ -19,7 +19,6 @@ func TestOrganizationsService_ListMembers(t *testing.T) { mux.HandleFunc("/orgs/o/members", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeOrgPermissionPreview) testFormValues(t, r, values{ "filter": "2fa_disabled", "role": "admin", @@ -39,7 +38,7 @@ func TestOrganizationsService_ListMembers(t *testing.T) { t.Errorf("Organizations.ListMembers returned error: %v", err) } - want := []User{{ID: Int(1)}} + want := []*User{{ID: Int(1)}} if !reflect.DeepEqual(members, want) { t.Errorf("Organizations.ListMembers returned %+v, want %+v", members, want) } @@ -65,7 +64,7 @@ func TestOrganizationsService_ListMembers_public(t *testing.T) { t.Errorf("Organizations.ListMembers returned error: %v", err) } - want := []User{{ID: Int(1)}} + want := []*User{{ID: Int(1)}} if !reflect.DeepEqual(members, want) { t.Errorf("Organizations.ListMembers returned %+v, want %+v", members, want) } @@ -236,7 +235,7 @@ func TestOrganizationsService_ListOrgMemberships(t *testing.T) { t.Errorf("Organizations.ListOrgMemberships returned error: %v", err) } - want := []Membership{{URL: String("u")}} + want := []*Membership{{URL: String("u")}} if !reflect.DeepEqual(memberships, want) { t.Errorf("Organizations.ListOrgMemberships returned %+v, want %+v", memberships, want) } diff --git a/vendor/github.com/google/go-github/github/orgs_teams.go b/vendor/github.com/google/go-github/github/orgs_teams.go index ddcaa24f..8e8550ce 100644 --- a/vendor/github.com/google/go-github/github/orgs_teams.go +++ b/vendor/github.com/google/go-github/github/orgs_teams.go @@ -44,7 +44,7 @@ func (t Team) String() string { // ListTeams lists all of the teams for an organization. // // GitHub API docs: http://developer.github.com/v3/orgs/teams/#list-teams -func (s *OrganizationsService) ListTeams(org string, opt *ListOptions) ([]Team, *Response, error) { +func (s *OrganizationsService) ListTeams(org string, opt *ListOptions) ([]*Team, *Response, error) { u := fmt.Sprintf("orgs/%v/teams", org) u, err := addOptions(u, opt) if err != nil { @@ -56,7 +56,7 @@ func (s *OrganizationsService) ListTeams(org string, opt *ListOptions) ([]Team, return nil, nil, err } - teams := new([]Team) + teams := new([]*Team) resp, err := s.client.Do(req, teams) if err != nil { return nil, resp, err @@ -94,10 +94,6 @@ func (s *OrganizationsService) CreateTeam(org string, team *Team) (*Team, *Respo return nil, nil, err } - if team.Privacy != nil { - req.Header.Set("Accept", mediaTypeOrgPermissionPreview) - } - t := new(Team) resp, err := s.client.Do(req, t) if err != nil { @@ -117,10 +113,6 @@ func (s *OrganizationsService) EditTeam(id int, team *Team) (*Team, *Response, e return nil, nil, err } - if team.Privacy != nil { - req.Header.Set("Accept", mediaTypeOrgPermissionPreview) - } - t := new(Team) resp, err := s.client.Do(req, t) if err != nil { @@ -157,7 +149,7 @@ type OrganizationListTeamMembersOptions struct { // team. // // GitHub API docs: http://developer.github.com/v3/orgs/teams/#list-team-members -func (s *OrganizationsService) ListTeamMembers(team int, opt *OrganizationListTeamMembersOptions) ([]User, *Response, error) { +func (s *OrganizationsService) ListTeamMembers(team int, opt *OrganizationListTeamMembersOptions) ([]*User, *Response, error) { u := fmt.Sprintf("teams/%v/members", team) u, err := addOptions(u, opt) if err != nil { @@ -169,11 +161,7 @@ func (s *OrganizationsService) ListTeamMembers(team int, opt *OrganizationListTe return nil, nil, err } - if opt != nil && opt.Role != "" { - req.Header.Set("Accept", mediaTypeOrgPermissionPreview) - } - - members := new([]User) + members := new([]*User) resp, err := s.client.Do(req, members) if err != nil { return nil, resp, err @@ -200,7 +188,7 @@ func (s *OrganizationsService) IsTeamMember(team int, user string) (bool, *Respo // ListTeamRepos lists the repositories that the specified team has access to. // // GitHub API docs: http://developer.github.com/v3/orgs/teams/#list-team-repos -func (s *OrganizationsService) ListTeamRepos(team int, opt *ListOptions) ([]Repository, *Response, error) { +func (s *OrganizationsService) ListTeamRepos(team int, opt *ListOptions) ([]*Repository, *Response, error) { u := fmt.Sprintf("teams/%v/repos", team) u, err := addOptions(u, opt) if err != nil { @@ -212,7 +200,7 @@ func (s *OrganizationsService) ListTeamRepos(team int, opt *ListOptions) ([]Repo return nil, nil, err } - repos := new([]Repository) + repos := new([]*Repository) resp, err := s.client.Do(req, repos) if err != nil { return nil, resp, err @@ -225,7 +213,7 @@ func (s *OrganizationsService) ListTeamRepos(team int, opt *ListOptions) ([]Repo // repository is managed by team, a Repository is returned which includes the // permissions team has for that repo. // -// GitHub API docs: http://developer.github.com/v3/orgs/teams/#get-team-repo +// GitHub API docs: https://developer.github.com/v3/orgs/teams/#check-if-a-team-manages-a-repository func (s *OrganizationsService) IsTeamRepo(team int, owner string, repo string) (*Repository, *Response, error) { u := fmt.Sprintf("teams/%v/repos/%v/%v", team, owner, repo) req, err := s.client.NewRequest("GET", u, nil) @@ -233,7 +221,7 @@ func (s *OrganizationsService) IsTeamRepo(team int, owner string, repo string) ( return nil, nil, err } - req.Header.Set("Accept", mediaTypeOrgPermissionRepoPreview) + req.Header.Set("Accept", mediaTypeOrgPermissionRepo) repository := new(Repository) resp, err := s.client.Do(req, repository) @@ -269,10 +257,6 @@ func (s *OrganizationsService) AddTeamRepo(team int, owner string, repo string, return nil, err } - if opt != nil { - req.Header.Set("Accept", mediaTypeOrgPermissionPreview) - } - return s.client.Do(req, nil) } @@ -293,7 +277,7 @@ func (s *OrganizationsService) RemoveTeamRepo(team int, owner string, repo strin // ListUserTeams lists a user's teams // GitHub API docs: https://developer.github.com/v3/orgs/teams/#list-user-teams -func (s *OrganizationsService) ListUserTeams(opt *ListOptions) ([]Team, *Response, error) { +func (s *OrganizationsService) ListUserTeams(opt *ListOptions) ([]*Team, *Response, error) { u := "user/teams" u, err := addOptions(u, opt) if err != nil { @@ -305,7 +289,7 @@ func (s *OrganizationsService) ListUserTeams(opt *ListOptions) ([]Team, *Respons return nil, nil, err } - teams := new([]Team) + teams := new([]*Team) resp, err := s.client.Do(req, teams) if err != nil { return nil, resp, err @@ -372,10 +356,6 @@ func (s *OrganizationsService) AddTeamMembership(team int, user string, opt *Org return nil, nil, err } - if opt != nil { - req.Header.Set("Accept", mediaTypeOrgPermissionPreview) - } - t := new(Membership) resp, err := s.client.Do(req, t) if err != nil { diff --git a/vendor/github.com/google/go-github/github/orgs_teams_test.go b/vendor/github.com/google/go-github/github/orgs_teams_test.go index a1d80f01..4dec1233 100644 --- a/vendor/github.com/google/go-github/github/orgs_teams_test.go +++ b/vendor/github.com/google/go-github/github/orgs_teams_test.go @@ -29,7 +29,7 @@ func TestOrganizationsService_ListTeams(t *testing.T) { t.Errorf("Organizations.ListTeams returned error: %v", err) } - want := []Team{{ID: Int(1)}} + want := []*Team{{ID: Int(1)}} if !reflect.DeepEqual(teams, want) { t.Errorf("Organizations.ListTeams returned %+v, want %+v", teams, want) } @@ -71,7 +71,6 @@ func TestOrganizationsService_CreateTeam(t *testing.T) { json.NewDecoder(r.Body).Decode(v) testMethod(t, r, "POST") - testHeader(t, r, "Accept", mediaTypeOrgPermissionPreview) if !reflect.DeepEqual(v, input) { t.Errorf("Request body = %+v, want %+v", v, input) } @@ -106,7 +105,6 @@ func TestOrganizationsService_EditTeam(t *testing.T) { json.NewDecoder(r.Body).Decode(v) testMethod(t, r, "PATCH") - testHeader(t, r, "Accept", mediaTypeOrgPermissionPreview) if !reflect.DeepEqual(v, input) { t.Errorf("Request body = %+v, want %+v", v, input) } @@ -145,7 +143,6 @@ func TestOrganizationsService_ListTeamMembers(t *testing.T) { mux.HandleFunc("/teams/1/members", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeOrgPermissionPreview) testFormValues(t, r, values{"role": "member", "page": "2"}) fmt.Fprint(w, `[{"id":1}]`) }) @@ -156,7 +153,7 @@ func TestOrganizationsService_ListTeamMembers(t *testing.T) { t.Errorf("Organizations.ListTeamMembers returned error: %v", err) } - want := []User{{ID: Int(1)}} + want := []*User{{ID: Int(1)}} if !reflect.DeepEqual(members, want) { t.Errorf("Organizations.ListTeamMembers returned %+v, want %+v", members, want) } @@ -279,7 +276,7 @@ func TestOrganizationsService_ListTeamRepos(t *testing.T) { t.Errorf("Organizations.ListTeamRepos returned error: %v", err) } - want := []Repository{{ID: Int(1)}} + want := []*Repository{{ID: Int(1)}} if !reflect.DeepEqual(members, want) { t.Errorf("Organizations.ListTeamRepos returned %+v, want %+v", members, want) } @@ -291,7 +288,7 @@ func TestOrganizationsService_IsTeamRepo_true(t *testing.T) { mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeOrgPermissionRepoPreview) + testHeader(t, r, "Accept", mediaTypeOrgPermissionRepo) fmt.Fprint(w, `{"id":1}`) }) @@ -364,7 +361,6 @@ func TestOrganizationsService_AddTeamRepo(t *testing.T) { json.NewDecoder(r.Body).Decode(v) testMethod(t, r, "PUT") - testHeader(t, r, "Accept", mediaTypeOrgPermissionPreview) if !reflect.DeepEqual(v, opt) { t.Errorf("Request body = %+v, want %+v", v, opt) } @@ -449,7 +445,6 @@ func TestOrganizationsService_AddTeamMembership(t *testing.T) { json.NewDecoder(r.Body).Decode(v) testMethod(t, r, "PUT") - testHeader(t, r, "Accept", mediaTypeOrgPermissionPreview) if !reflect.DeepEqual(v, opt) { t.Errorf("Request body = %+v, want %+v", v, opt) } @@ -499,7 +494,7 @@ func TestOrganizationsService_ListUserTeams(t *testing.T) { t.Errorf("Organizations.ListUserTeams returned error: %v", err) } - want := []Team{{ID: Int(1)}} + want := []*Team{{ID: Int(1)}} if !reflect.DeepEqual(teams, want) { t.Errorf("Organizations.ListUserTeams returned %+v, want %+v", teams, want) } diff --git a/vendor/github.com/google/go-github/github/orgs_test.go b/vendor/github.com/google/go-github/github/orgs_test.go index 3c32aaec..8e02619d 100644 --- a/vendor/github.com/google/go-github/github/orgs_test.go +++ b/vendor/github.com/google/go-github/github/orgs_test.go @@ -30,7 +30,7 @@ func TestOrganizationsService_ListAll(t *testing.T) { t.Errorf("Organizations.ListAll returned error: %v", err) } - want := []Organization{{ID: Int(4314092)}} + want := []*Organization{{ID: Int(4314092)}} if !reflect.DeepEqual(orgs, want) { t.Errorf("Organizations.ListAll returned %+v, want %+v", orgs, want) } @@ -50,7 +50,7 @@ func TestOrganizationsService_List_authenticatedUser(t *testing.T) { t.Errorf("Organizations.List returned error: %v", err) } - want := []Organization{{ID: Int(1)}, {ID: Int(2)}} + want := []*Organization{{ID: Int(1)}, {ID: Int(2)}} if !reflect.DeepEqual(orgs, want) { t.Errorf("Organizations.List returned %+v, want %+v", orgs, want) } @@ -72,7 +72,7 @@ func TestOrganizationsService_List_specifiedUser(t *testing.T) { t.Errorf("Organizations.List returned error: %v", err) } - want := []Organization{{ID: Int(1)}, {ID: Int(2)}} + want := []*Organization{{ID: Int(1)}, {ID: Int(2)}} if !reflect.DeepEqual(orgs, want) { t.Errorf("Organizations.List returned %+v, want %+v", orgs, want) } diff --git a/vendor/github.com/google/go-github/github/pulls.go b/vendor/github.com/google/go-github/github/pulls.go index 8f31ab55..535ee46a 100644 --- a/vendor/github.com/google/go-github/github/pulls.go +++ b/vendor/github.com/google/go-github/github/pulls.go @@ -91,7 +91,7 @@ type PullRequestListOptions struct { // List the pull requests for the specified repository. // // GitHub API docs: http://developer.github.com/v3/pulls/#list-pull-requests -func (s *PullRequestsService) List(owner string, repo string, opt *PullRequestListOptions) ([]PullRequest, *Response, error) { +func (s *PullRequestsService) List(owner string, repo string, opt *PullRequestListOptions) ([]*PullRequest, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls", owner, repo) u, err := addOptions(u, opt) if err != nil { @@ -103,7 +103,7 @@ func (s *PullRequestsService) List(owner string, repo string, opt *PullRequestLi return nil, nil, err } - pulls := new([]PullRequest) + pulls := new([]*PullRequest) resp, err := s.client.Do(req, pulls) if err != nil { return nil, resp, err @@ -181,7 +181,7 @@ func (s *PullRequestsService) Edit(owner string, repo string, number int, pull * // ListCommits lists the commits in a pull request. // // GitHub API docs: https://developer.github.com/v3/pulls/#list-commits-on-a-pull-request -func (s *PullRequestsService) ListCommits(owner string, repo string, number int, opt *ListOptions) ([]RepositoryCommit, *Response, error) { +func (s *PullRequestsService) ListCommits(owner string, repo string, number int, opt *ListOptions) ([]*RepositoryCommit, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/commits", owner, repo, number) u, err := addOptions(u, opt) if err != nil { @@ -193,7 +193,7 @@ func (s *PullRequestsService) ListCommits(owner string, repo string, number int, return nil, nil, err } - commits := new([]RepositoryCommit) + commits := new([]*RepositoryCommit) resp, err := s.client.Do(req, commits) if err != nil { return nil, resp, err @@ -205,7 +205,7 @@ func (s *PullRequestsService) ListCommits(owner string, repo string, number int, // ListFiles lists the files in a pull request. // // GitHub API docs: https://developer.github.com/v3/pulls/#list-pull-requests-files -func (s *PullRequestsService) ListFiles(owner string, repo string, number int, opt *ListOptions) ([]CommitFile, *Response, error) { +func (s *PullRequestsService) ListFiles(owner string, repo string, number int, opt *ListOptions) ([]*CommitFile, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/files", owner, repo, number) u, err := addOptions(u, opt) if err != nil { @@ -217,7 +217,7 @@ func (s *PullRequestsService) ListFiles(owner string, repo string, number int, o return nil, nil, err } - commitFiles := new([]CommitFile) + commitFiles := new([]*CommitFile) resp, err := s.client.Do(req, commitFiles) if err != nil { return nil, resp, err @@ -248,20 +248,30 @@ type PullRequestMergeResult struct { Message *string `json:"message,omitempty"` } +// PullRequestOptions lets you define how a pull request will be merged. +type PullRequestOptions struct { + Squash bool +} + type pullRequestMergeRequest struct { CommitMessage *string `json:"commit_message"` + Squash *bool `json:"squash,omitempty"` } // Merge a pull request (Merge Button™). // // GitHub API docs: https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-buttontrade -func (s *PullRequestsService) Merge(owner string, repo string, number int, commitMessage string) (*PullRequestMergeResult, *Response, error) { +func (s *PullRequestsService) Merge(owner string, repo string, number int, commitMessage string, options *PullRequestOptions) (*PullRequestMergeResult, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/merge", owner, repo, number) - req, err := s.client.NewRequest("PUT", u, &pullRequestMergeRequest{ - CommitMessage: &commitMessage, - }) + pullRequestBody := &pullRequestMergeRequest{CommitMessage: &commitMessage} + if options != nil { + pullRequestBody.Squash = &options.Squash + } + req, err := s.client.NewRequest("PUT", u, pullRequestBody) + // TODO: This header will be unnecessary when the API is no longer in preview. + req.Header.Set("Accept", mediaTypeSquashPreview) if err != nil { return nil, nil, err } diff --git a/vendor/github.com/google/go-github/github/pulls_comments.go b/vendor/github.com/google/go-github/github/pulls_comments.go index 247f1796..c7af85a8 100644 --- a/vendor/github.com/google/go-github/github/pulls_comments.go +++ b/vendor/github.com/google/go-github/github/pulls_comments.go @@ -54,7 +54,7 @@ type PullRequestListCommentsOptions struct { // the repository. // // GitHub API docs: https://developer.github.com/v3/pulls/comments/#list-comments-on-a-pull-request -func (s *PullRequestsService) ListComments(owner string, repo string, number int, opt *PullRequestListCommentsOptions) ([]PullRequestComment, *Response, error) { +func (s *PullRequestsService) ListComments(owner string, repo string, number int, opt *PullRequestListCommentsOptions) ([]*PullRequestComment, *Response, error) { var u string if number == 0 { u = fmt.Sprintf("repos/%v/%v/pulls/comments", owner, repo) @@ -74,7 +74,7 @@ func (s *PullRequestsService) ListComments(owner string, repo string, number int // TODO: remove custom Accept header when this API fully launches. req.Header.Set("Accept", mediaTypeReactionsPreview) - comments := new([]PullRequestComment) + comments := new([]*PullRequestComment) resp, err := s.client.Do(req, comments) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/pulls_comments_test.go b/vendor/github.com/google/go-github/github/pulls_comments_test.go index 8882456c..5412ac88 100644 --- a/vendor/github.com/google/go-github/github/pulls_comments_test.go +++ b/vendor/github.com/google/go-github/github/pulls_comments_test.go @@ -37,12 +37,11 @@ func TestPullRequestsService_ListComments_allPulls(t *testing.T) { ListOptions: ListOptions{Page: 2}, } pulls, _, err := client.PullRequests.ListComments("o", "r", 0, opt) - if err != nil { t.Errorf("PullRequests.ListComments returned error: %v", err) } - want := []PullRequestComment{{ID: Int(1)}} + want := []*PullRequestComment{{ID: Int(1)}} if !reflect.DeepEqual(pulls, want) { t.Errorf("PullRequests.ListComments returned %+v, want %+v", pulls, want) } @@ -59,12 +58,11 @@ func TestPullRequestsService_ListComments_specificPull(t *testing.T) { }) pulls, _, err := client.PullRequests.ListComments("o", "r", 1, nil) - if err != nil { t.Errorf("PullRequests.ListComments returned error: %v", err) } - want := []PullRequestComment{{ID: Int(1)}} + want := []*PullRequestComment{{ID: Int(1)}} if !reflect.DeepEqual(pulls, want) { t.Errorf("PullRequests.ListComments returned %+v, want %+v", pulls, want) } @@ -86,7 +84,6 @@ func TestPullRequestsService_GetComment(t *testing.T) { }) comment, _, err := client.PullRequests.GetComment("o", "r", 1) - if err != nil { t.Errorf("PullRequests.GetComment returned error: %v", err) } @@ -121,7 +118,6 @@ func TestPullRequestsService_CreateComment(t *testing.T) { }) comment, _, err := client.PullRequests.CreateComment("o", "r", 1, input) - if err != nil { t.Errorf("PullRequests.CreateComment returned error: %v", err) } @@ -156,7 +152,6 @@ func TestPullRequestsService_EditComment(t *testing.T) { }) comment, _, err := client.PullRequests.EditComment("o", "r", 1, input) - if err != nil { t.Errorf("PullRequests.EditComment returned error: %v", err) } diff --git a/vendor/github.com/google/go-github/github/pulls_test.go b/vendor/github.com/google/go-github/github/pulls_test.go index 6ac0ddb1..1f8c58c2 100644 --- a/vendor/github.com/google/go-github/github/pulls_test.go +++ b/vendor/github.com/google/go-github/github/pulls_test.go @@ -32,12 +32,11 @@ func TestPullRequestsService_List(t *testing.T) { opt := &PullRequestListOptions{"closed", "h", "b", "created", "desc", ListOptions{Page: 2}} pulls, _, err := client.PullRequests.List("o", "r", opt) - if err != nil { t.Errorf("PullRequests.List returned error: %v", err) } - want := []PullRequest{{Number: Int(1)}} + want := []*PullRequest{{Number: Int(1)}} if !reflect.DeepEqual(pulls, want) { t.Errorf("PullRequests.List returned %+v, want %+v", pulls, want) } @@ -58,7 +57,6 @@ func TestPullRequestsService_Get(t *testing.T) { }) pull, _, err := client.PullRequests.Get("o", "r", 1) - if err != nil { t.Errorf("PullRequests.Get returned error: %v", err) } @@ -79,7 +77,6 @@ func TestPullRequestsService_Get_headAndBase(t *testing.T) { }) pull, _, err := client.PullRequests.Get("o", "r", 1) - if err != nil { t.Errorf("PullRequests.Get returned error: %v", err) } @@ -112,7 +109,6 @@ func TestPullRequestService_Get_DiffURLAndPatchURL(t *testing.T) { }) pull, _, err := client.PullRequests.Get("o", "r", 1) - if err != nil { t.Errorf("PullRequests.Get returned error: %v", err) } @@ -230,7 +226,7 @@ func TestPullRequestsService_ListCommits(t *testing.T) { t.Errorf("PullRequests.ListCommits returned error: %v", err) } - want := []RepositoryCommit{ + want := []*RepositoryCommit{ { SHA: String("3"), Parents: []Commit{ @@ -289,7 +285,7 @@ func TestPullRequestsService_ListFiles(t *testing.T) { t.Errorf("PullRequests.ListFiles returned error: %v", err) } - want := []CommitFile{ + want := []*CommitFile{ { SHA: String("6dcb09b5b57875f334f61aebed695e2e4193db5e"), Filename: String("file1.txt"), @@ -341,6 +337,7 @@ func TestPullRequestsService_Merge(t *testing.T) { mux.HandleFunc("/repos/o/r/pulls/1/merge", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") + testHeader(t, r, "Accept", mediaTypeSquashPreview) fmt.Fprint(w, ` { "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e", @@ -349,7 +346,8 @@ func TestPullRequestsService_Merge(t *testing.T) { }`) }) - merge, _, err := client.PullRequests.Merge("o", "r", 1, "merging pull request") + options := &PullRequestOptions{Squash: true} + merge, _, err := client.PullRequests.Merge("o", "r", 1, "merging pull request", options) if err != nil { t.Errorf("PullRequests.Merge returned error: %v", err) } diff --git a/vendor/github.com/google/go-github/github/reactions.go b/vendor/github.com/google/go-github/github/reactions.go index 283938ad..68a16af1 100644 --- a/vendor/github.com/google/go-github/github/reactions.go +++ b/vendor/github.com/google/go-github/github/reactions.go @@ -18,8 +18,8 @@ type ReactionsService struct { // Reaction represents a GitHub reaction. type Reaction struct { // ID is the Reaction ID. - ID *int `json:"id,omitempty"` - UserID *int `json:"user_id,omitempty"` + ID *int `json:"id,omitempty"` + User *User `json:"user,omitempty"` // Content is the type of reaction. // Possible values are: // "+1", "-1", "laugh", "confused", "heart", "hooray". @@ -258,7 +258,7 @@ func (s ReactionsService) CreatePullRequestCommentReaction(owner, repo string, i // // GitHub API docs: https://developer.github.com/v3/reaction/reactions/#delete-a-reaction-archive func (s *ReactionsService) DeleteReaction(id int) (*Response, error) { - u := fmt.Sprintf("/reactions/%v", id) + u := fmt.Sprintf("reactions/%v", id) req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { diff --git a/vendor/github.com/google/go-github/github/reactions_test.go b/vendor/github.com/google/go-github/github/reactions_test.go index 010cb8cf..91ef9b50 100644 --- a/vendor/github.com/google/go-github/github/reactions_test.go +++ b/vendor/github.com/google/go-github/github/reactions_test.go @@ -20,14 +20,14 @@ func TestReactionsService_ListCommentReactions(t *testing.T) { testHeader(t, r, "Accept", mediaTypeReactionsPreview) w.WriteHeader(http.StatusOK) - w.Write([]byte(`[{"id":1,"user_id":2,"content":"+1"}]`)) + w.Write([]byte(`[{"id":1,"user":{"login":"l","id":2},"content":"+1"}]`)) }) got, _, err := client.Reactions.ListCommentReactions("o", "r", 1, nil) if err != nil { t.Errorf("ListCommentReactions returned error: %v", err) } - if want := []*Reaction{{ID: Int(1), UserID: Int(2), Content: String("+1")}}; !reflect.DeepEqual(got, want) { + if want := []*Reaction{{ID: Int(1), User: &User{Login: String("l"), ID: Int(2)}, Content: String("+1")}}; !reflect.DeepEqual(got, want) { t.Errorf("ListCommentReactions = %+v, want %+v", got, want) } } @@ -41,14 +41,14 @@ func TestReactionsService_CreateCommentReaction(t *testing.T) { testHeader(t, r, "Accept", mediaTypeReactionsPreview) w.WriteHeader(http.StatusCreated) - w.Write([]byte(`{"id":1,"user_id":2,"content":"+1"}`)) + w.Write([]byte(`{"id":1,"user":{"login":"l","id":2},"content":"+1"}`)) }) got, _, err := client.Reactions.CreateCommentReaction("o", "r", 1, "+1") if err != nil { t.Errorf("CreateCommentReaction returned error: %v", err) } - want := &Reaction{ID: Int(1), UserID: Int(2), Content: String("+1")} + want := &Reaction{ID: Int(1), User: &User{Login: String("l"), ID: Int(2)}, Content: String("+1")} if !reflect.DeepEqual(got, want) { t.Errorf("CreateCommentReaction = %+v, want %+v", got, want) } @@ -63,14 +63,14 @@ func TestReactionsService_ListIssueReactions(t *testing.T) { testHeader(t, r, "Accept", mediaTypeReactionsPreview) w.WriteHeader(http.StatusOK) - w.Write([]byte(`[{"id":1,"user_id":2,"content":"+1"}]`)) + w.Write([]byte(`[{"id":1,"user":{"login":"l","id":2},"content":"+1"}]`)) }) got, _, err := client.Reactions.ListIssueReactions("o", "r", 1, nil) if err != nil { t.Errorf("ListIssueReactions returned error: %v", err) } - if want := []*Reaction{{ID: Int(1), UserID: Int(2), Content: String("+1")}}; !reflect.DeepEqual(got, want) { + if want := []*Reaction{{ID: Int(1), User: &User{Login: String("l"), ID: Int(2)}, Content: String("+1")}}; !reflect.DeepEqual(got, want) { t.Errorf("ListIssueReactions = %+v, want %+v", got, want) } } @@ -84,14 +84,14 @@ func TestReactionsService_CreateIssueReaction(t *testing.T) { testHeader(t, r, "Accept", mediaTypeReactionsPreview) w.WriteHeader(http.StatusCreated) - w.Write([]byte(`{"id":1,"user_id":2,"content":"+1"}`)) + w.Write([]byte(`{"id":1,"user":{"login":"l","id":2},"content":"+1"}`)) }) got, _, err := client.Reactions.CreateIssueReaction("o", "r", 1, "+1") if err != nil { t.Errorf("CreateIssueReaction returned error: %v", err) } - want := &Reaction{ID: Int(1), UserID: Int(2), Content: String("+1")} + want := &Reaction{ID: Int(1), User: &User{Login: String("l"), ID: Int(2)}, Content: String("+1")} if !reflect.DeepEqual(got, want) { t.Errorf("CreateIssueReaction = %+v, want %+v", got, want) } @@ -106,14 +106,14 @@ func TestReactionsService_ListIssueCommentReactions(t *testing.T) { testHeader(t, r, "Accept", mediaTypeReactionsPreview) w.WriteHeader(http.StatusOK) - w.Write([]byte(`[{"id":1,"user_id":2,"content":"+1"}]`)) + w.Write([]byte(`[{"id":1,"user":{"login":"l","id":2},"content":"+1"}]`)) }) got, _, err := client.Reactions.ListIssueCommentReactions("o", "r", 1, nil) if err != nil { t.Errorf("ListIssueCommentReactions returned error: %v", err) } - if want := []*Reaction{{ID: Int(1), UserID: Int(2), Content: String("+1")}}; !reflect.DeepEqual(got, want) { + if want := []*Reaction{{ID: Int(1), User: &User{Login: String("l"), ID: Int(2)}, Content: String("+1")}}; !reflect.DeepEqual(got, want) { t.Errorf("ListIssueCommentReactions = %+v, want %+v", got, want) } } @@ -127,14 +127,14 @@ func TestReactionsService_CreateIssueCommentReaction(t *testing.T) { testHeader(t, r, "Accept", mediaTypeReactionsPreview) w.WriteHeader(http.StatusCreated) - w.Write([]byte(`{"id":1,"user_id":2,"content":"+1"}`)) + w.Write([]byte(`{"id":1,"user":{"login":"l","id":2},"content":"+1"}`)) }) got, _, err := client.Reactions.CreateIssueCommentReaction("o", "r", 1, "+1") if err != nil { t.Errorf("CreateIssueCommentReaction returned error: %v", err) } - want := &Reaction{ID: Int(1), UserID: Int(2), Content: String("+1")} + want := &Reaction{ID: Int(1), User: &User{Login: String("l"), ID: Int(2)}, Content: String("+1")} if !reflect.DeepEqual(got, want) { t.Errorf("CreateIssueCommentReaction = %+v, want %+v", got, want) } @@ -149,14 +149,14 @@ func TestReactionsService_ListPullRequestCommentReactions(t *testing.T) { testHeader(t, r, "Accept", mediaTypeReactionsPreview) w.WriteHeader(http.StatusOK) - w.Write([]byte(`[{"id":1,"user_id":2,"content":"+1"}]`)) + w.Write([]byte(`[{"id":1,"user":{"login":"l","id":2},"content":"+1"}]`)) }) got, _, err := client.Reactions.ListPullRequestCommentReactions("o", "r", 1, nil) if err != nil { t.Errorf("ListPullRequestCommentReactions returned error: %v", err) } - if want := []*Reaction{{ID: Int(1), UserID: Int(2), Content: String("+1")}}; !reflect.DeepEqual(got, want) { + if want := []*Reaction{{ID: Int(1), User: &User{Login: String("l"), ID: Int(2)}, Content: String("+1")}}; !reflect.DeepEqual(got, want) { t.Errorf("ListPullRequestCommentReactions = %+v, want %+v", got, want) } } @@ -170,14 +170,14 @@ func TestReactionsService_CreatePullRequestCommentReaction(t *testing.T) { testHeader(t, r, "Accept", mediaTypeReactionsPreview) w.WriteHeader(http.StatusCreated) - w.Write([]byte(`{"id":1,"user_id":2,"content":"+1"}`)) + w.Write([]byte(`{"id":1,"user":{"login":"l","id":2},"content":"+1"}`)) }) got, _, err := client.Reactions.CreatePullRequestCommentReaction("o", "r", 1, "+1") if err != nil { t.Errorf("CreatePullRequestCommentReaction returned error: %v", err) } - want := &Reaction{ID: Int(1), UserID: Int(2), Content: String("+1")} + want := &Reaction{ID: Int(1), User: &User{Login: String("l"), ID: Int(2)}, Content: String("+1")} if !reflect.DeepEqual(got, want) { t.Errorf("CreatePullRequestCommentReaction = %+v, want %+v", got, want) } diff --git a/vendor/github.com/google/go-github/github/repos.go b/vendor/github.com/google/go-github/github/repos.go index 4909b16c..ffefce99 100644 --- a/vendor/github.com/google/go-github/github/repos.go +++ b/vendor/github.com/google/go-github/github/repos.go @@ -110,16 +110,33 @@ func (r Repository) String() string { // RepositoryListOptions specifies the optional parameters to the // RepositoriesService.List method. type RepositoryListOptions struct { - // Type of repositories to list. Possible values are: all, owner, public, - // private, member. Default is "all". + // Visibility of repositories to list. Can be one of all, public, or private. + // Default: all + Visibility string `url:"visibility,omitempty"` + + // List repos of given affiliation[s]. + // Comma-separated list of values. Can include: + // * owner: Repositories that are owned by the authenticated user. + // * collaborator: Repositories that the user has been added to as a + // collaborator. + // * organization_member: Repositories that the user has access to through + // being a member of an organization. This includes every repository on + // every team that the user is on. + // Default: owner,collaborator,organization_member + Affiliation string `url:"affiliation,omitempty"` + + // Type of repositories to list. + // Can be one of all, owner, public, private, member. Default: all + // Will cause a 422 error if used in the same request as visibility or + // affiliation. Type string `url:"type,omitempty"` - // How to sort the repository list. Possible values are: created, updated, - // pushed, full_name. Default is "full_name". + // How to sort the repository list. Can be one of created, updated, pushed, + // full_name. Default: full_name Sort string `url:"sort,omitempty"` - // Direction in which to sort repositories. Possible values are: asc, desc. - // Default is "asc" when sort is "full_name", otherwise default is "desc". + // Direction in which to sort repositories. Can be one of asc or desc. + // Default: when using full_name: asc; otherwise desc Direction string `url:"direction,omitempty"` ListOptions @@ -129,7 +146,7 @@ type RepositoryListOptions struct { // repositories for the authenticated user. // // GitHub API docs: http://developer.github.com/v3/repos/#list-user-repositories -func (s *RepositoriesService) List(user string, opt *RepositoryListOptions) ([]Repository, *Response, error) { +func (s *RepositoriesService) List(user string, opt *RepositoryListOptions) ([]*Repository, *Response, error) { var u string if user != "" { u = fmt.Sprintf("users/%v/repos", user) @@ -149,7 +166,7 @@ func (s *RepositoriesService) List(user string, opt *RepositoryListOptions) ([]R // TODO: remove custom Accept header when license support fully launches req.Header.Set("Accept", mediaTypeLicensesPreview) - repos := new([]Repository) + repos := new([]*Repository) resp, err := s.client.Do(req, repos) if err != nil { return nil, resp, err @@ -171,7 +188,7 @@ type RepositoryListByOrgOptions struct { // ListByOrg lists the repositories for an organization. // // GitHub API docs: http://developer.github.com/v3/repos/#list-organization-repositories -func (s *RepositoriesService) ListByOrg(org string, opt *RepositoryListByOrgOptions) ([]Repository, *Response, error) { +func (s *RepositoriesService) ListByOrg(org string, opt *RepositoryListByOrgOptions) ([]*Repository, *Response, error) { u := fmt.Sprintf("orgs/%v/repos", org) u, err := addOptions(u, opt) if err != nil { @@ -186,7 +203,7 @@ func (s *RepositoriesService) ListByOrg(org string, opt *RepositoryListByOrgOpti // TODO: remove custom Accept header when license support fully launches req.Header.Set("Accept", mediaTypeLicensesPreview) - repos := new([]Repository) + repos := new([]*Repository) resp, err := s.client.Do(req, repos) if err != nil { return nil, resp, err @@ -207,7 +224,7 @@ type RepositoryListAllOptions struct { // ListAll lists all GitHub repositories in the order that they were created. // // GitHub API docs: http://developer.github.com/v3/repos/#list-all-public-repositories -func (s *RepositoriesService) ListAll(opt *RepositoryListAllOptions) ([]Repository, *Response, error) { +func (s *RepositoriesService) ListAll(opt *RepositoryListAllOptions) ([]*Repository, *Response, error) { u, err := addOptions("repositories", opt) if err != nil { return nil, nil, err @@ -218,7 +235,7 @@ func (s *RepositoriesService) ListAll(opt *RepositoryListAllOptions) ([]Reposito return nil, nil, err } - repos := new([]Repository) + repos := new([]*Repository) resp, err := s.client.Do(req, repos) if err != nil { return nil, resp, err @@ -366,7 +383,7 @@ type ListContributorsOptions struct { // ListContributors lists contributors for a repository. // // GitHub API docs: http://developer.github.com/v3/repos/#list-contributors -func (s *RepositoriesService) ListContributors(owner string, repository string, opt *ListContributorsOptions) ([]Contributor, *Response, error) { +func (s *RepositoriesService) ListContributors(owner string, repository string, opt *ListContributorsOptions) ([]*Contributor, *Response, error) { u := fmt.Sprintf("repos/%v/%v/contributors", owner, repository) u, err := addOptions(u, opt) if err != nil { @@ -378,7 +395,7 @@ func (s *RepositoriesService) ListContributors(owner string, repository string, return nil, nil, err } - contributor := new([]Contributor) + contributor := new([]*Contributor) resp, err := s.client.Do(req, contributor) if err != nil { return nil, nil, err @@ -416,7 +433,7 @@ func (s *RepositoriesService) ListLanguages(owner string, repo string) (map[stri // ListTeams lists the teams for the specified repository. // // GitHub API docs: https://developer.github.com/v3/repos/#list-teams -func (s *RepositoriesService) ListTeams(owner string, repo string, opt *ListOptions) ([]Team, *Response, error) { +func (s *RepositoriesService) ListTeams(owner string, repo string, opt *ListOptions) ([]*Team, *Response, error) { u := fmt.Sprintf("repos/%v/%v/teams", owner, repo) u, err := addOptions(u, opt) if err != nil { @@ -428,7 +445,7 @@ func (s *RepositoriesService) ListTeams(owner string, repo string, opt *ListOpti return nil, nil, err } - teams := new([]Team) + teams := new([]*Team) resp, err := s.client.Do(req, teams) if err != nil { return nil, resp, err @@ -448,7 +465,7 @@ type RepositoryTag struct { // ListTags lists tags for the specified repository. // // GitHub API docs: https://developer.github.com/v3/repos/#list-tags -func (s *RepositoriesService) ListTags(owner string, repo string, opt *ListOptions) ([]RepositoryTag, *Response, error) { +func (s *RepositoriesService) ListTags(owner string, repo string, opt *ListOptions) ([]*RepositoryTag, *Response, error) { u := fmt.Sprintf("repos/%v/%v/tags", owner, repo) u, err := addOptions(u, opt) if err != nil { @@ -460,7 +477,7 @@ func (s *RepositoriesService) ListTags(owner string, repo string, opt *ListOptio return nil, nil, err } - tags := new([]RepositoryTag) + tags := new([]*RepositoryTag) resp, err := s.client.Do(req, tags) if err != nil { return nil, resp, err @@ -497,7 +514,7 @@ type RequiredStatusChecks struct { // ListBranches lists branches for the specified repository. // // GitHub API docs: http://developer.github.com/v3/repos/#list-branches -func (s *RepositoriesService) ListBranches(owner string, repo string, opt *ListOptions) ([]Branch, *Response, error) { +func (s *RepositoriesService) ListBranches(owner string, repo string, opt *ListOptions) ([]*Branch, *Response, error) { u := fmt.Sprintf("repos/%v/%v/branches", owner, repo) u, err := addOptions(u, opt) if err != nil { @@ -511,7 +528,7 @@ func (s *RepositoriesService) ListBranches(owner string, repo string, opt *ListO req.Header.Set("Accept", mediaTypeProtectedBranchesPreview) - branches := new([]Branch) + branches := new([]*Branch) resp, err := s.client.Do(req, branches) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/repos_collaborators.go b/vendor/github.com/google/go-github/github/repos_collaborators.go index 61dc4ef2..68a9f466 100644 --- a/vendor/github.com/google/go-github/github/repos_collaborators.go +++ b/vendor/github.com/google/go-github/github/repos_collaborators.go @@ -10,7 +10,7 @@ import "fmt" // ListCollaborators lists the Github users that have access to the repository. // // GitHub API docs: http://developer.github.com/v3/repos/collaborators/#list -func (s *RepositoriesService) ListCollaborators(owner, repo string, opt *ListOptions) ([]User, *Response, error) { +func (s *RepositoriesService) ListCollaborators(owner, repo string, opt *ListOptions) ([]*User, *Response, error) { u := fmt.Sprintf("repos/%v/%v/collaborators", owner, repo) u, err := addOptions(u, opt) if err != nil { @@ -22,9 +22,7 @@ func (s *RepositoriesService) ListCollaborators(owner, repo string, opt *ListOpt return nil, nil, err } - req.Header.Set("Accept", mediaTypeOrgPermissionPreview) - - users := new([]User) + users := new([]*User) resp, err := s.client.Do(req, users) if err != nil { return nil, resp, err @@ -60,13 +58,13 @@ type RepositoryAddCollaboratorOptions struct { // push - team members can pull and push, but not administer this repository // admin - team members can pull, push and administer this repository // - // Default value is "pull". This option is only valid for organization-owned repositories. + // Default value is "push". This option is only valid for organization-owned repositories. Permission string `json:"permission,omitempty"` } // AddCollaborator adds the specified Github user as collaborator to the given repo. // -// GitHub API docs: http://developer.github.com/v3/repos/collaborators/#add-collaborator +// GitHub API docs: https://developer.github.com/v3/repos/collaborators/#add-user-as-a-collaborator func (s *RepositoriesService) AddCollaborator(owner, repo, user string, opt *RepositoryAddCollaboratorOptions) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/collaborators/%v", owner, repo, user) req, err := s.client.NewRequest("PUT", u, opt) @@ -74,9 +72,8 @@ func (s *RepositoriesService) AddCollaborator(owner, repo, user string, opt *Rep return nil, err } - if opt != nil { - req.Header.Set("Accept", mediaTypeOrgPermissionPreview) - } + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeRepositoryInvitationsPreview) return s.client.Do(req, nil) } diff --git a/vendor/github.com/google/go-github/github/repos_collaborators_test.go b/vendor/github.com/google/go-github/github/repos_collaborators_test.go index ee6c4989..75e3cf39 100644 --- a/vendor/github.com/google/go-github/github/repos_collaborators_test.go +++ b/vendor/github.com/google/go-github/github/repos_collaborators_test.go @@ -19,7 +19,6 @@ func TestRepositoriesService_ListCollaborators(t *testing.T) { mux.HandleFunc("/repos/o/r/collaborators", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - testHeader(t, r, "Accept", mediaTypeOrgPermissionPreview) testFormValues(t, r, values{"page": "2"}) fmt.Fprintf(w, `[{"id":1}, {"id":2}]`) }) @@ -30,7 +29,7 @@ func TestRepositoriesService_ListCollaborators(t *testing.T) { t.Errorf("Repositories.ListCollaborators returned error: %v", err) } - want := []User{{ID: Int(1)}, {ID: Int(2)}} + want := []*User{{ID: Int(1)}, {ID: Int(2)}} if !reflect.DeepEqual(users, want) { t.Errorf("Repositories.ListCollaborators returned %+v, want %+v", users, want) } @@ -95,7 +94,7 @@ func TestRepositoriesService_AddCollaborator(t *testing.T) { json.NewDecoder(r.Body).Decode(v) testMethod(t, r, "PUT") - testHeader(t, r, "Accept", mediaTypeOrgPermissionPreview) + testHeader(t, r, "Accept", mediaTypeRepositoryInvitationsPreview) if !reflect.DeepEqual(v, opt) { t.Errorf("Request body = %+v, want %+v", v, opt) } diff --git a/vendor/github.com/google/go-github/github/repos_comments.go b/vendor/github.com/google/go-github/github/repos_comments.go index bba0fe74..34a8d020 100644 --- a/vendor/github.com/google/go-github/github/repos_comments.go +++ b/vendor/github.com/google/go-github/github/repos_comments.go @@ -35,7 +35,7 @@ func (r RepositoryComment) String() string { // ListComments lists all the comments for the repository. // // GitHub API docs: http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository -func (s *RepositoriesService) ListComments(owner, repo string, opt *ListOptions) ([]RepositoryComment, *Response, error) { +func (s *RepositoriesService) ListComments(owner, repo string, opt *ListOptions) ([]*RepositoryComment, *Response, error) { u := fmt.Sprintf("repos/%v/%v/comments", owner, repo) u, err := addOptions(u, opt) if err != nil { @@ -50,7 +50,7 @@ func (s *RepositoriesService) ListComments(owner, repo string, opt *ListOptions) // TODO: remove custom Accept header when this API fully launches. req.Header.Set("Accept", mediaTypeReactionsPreview) - comments := new([]RepositoryComment) + comments := new([]*RepositoryComment) resp, err := s.client.Do(req, comments) if err != nil { return nil, resp, err @@ -62,7 +62,7 @@ func (s *RepositoriesService) ListComments(owner, repo string, opt *ListOptions) // ListCommitComments lists all the comments for a given commit SHA. // // GitHub API docs: http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit -func (s *RepositoriesService) ListCommitComments(owner, repo, sha string, opt *ListOptions) ([]RepositoryComment, *Response, error) { +func (s *RepositoriesService) ListCommitComments(owner, repo, sha string, opt *ListOptions) ([]*RepositoryComment, *Response, error) { u := fmt.Sprintf("repos/%v/%v/commits/%v/comments", owner, repo, sha) u, err := addOptions(u, opt) if err != nil { @@ -77,7 +77,7 @@ func (s *RepositoriesService) ListCommitComments(owner, repo, sha string, opt *L // TODO: remove custom Accept header when this API fully launches. req.Header.Set("Accept", mediaTypeReactionsPreview) - comments := new([]RepositoryComment) + comments := new([]*RepositoryComment) resp, err := s.client.Do(req, comments) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/repos_comments_test.go b/vendor/github.com/google/go-github/github/repos_comments_test.go index ddede06b..924a9a40 100644 --- a/vendor/github.com/google/go-github/github/repos_comments_test.go +++ b/vendor/github.com/google/go-github/github/repos_comments_test.go @@ -30,7 +30,7 @@ func TestRepositoriesService_ListComments(t *testing.T) { t.Errorf("Repositories.ListComments returned error: %v", err) } - want := []RepositoryComment{{ID: Int(1)}, {ID: Int(2)}} + want := []*RepositoryComment{{ID: Int(1)}, {ID: Int(2)}} if !reflect.DeepEqual(comments, want) { t.Errorf("Repositories.ListComments returned %+v, want %+v", comments, want) } @@ -58,7 +58,7 @@ func TestRepositoriesService_ListCommitComments(t *testing.T) { t.Errorf("Repositories.ListCommitComments returned error: %v", err) } - want := []RepositoryComment{{ID: Int(1)}, {ID: Int(2)}} + want := []*RepositoryComment{{ID: Int(1)}, {ID: Int(2)}} if !reflect.DeepEqual(comments, want) { t.Errorf("Repositories.ListCommitComments returned %+v, want %+v", comments, want) } diff --git a/vendor/github.com/google/go-github/github/repos_commits.go b/vendor/github.com/google/go-github/github/repos_commits.go index 9cbdbfdb..b5e6856b 100644 --- a/vendor/github.com/google/go-github/github/repos_commits.go +++ b/vendor/github.com/google/go-github/github/repos_commits.go @@ -33,7 +33,7 @@ func (r RepositoryCommit) String() string { return Stringify(r) } -// CommitStats represents the number of additions / deletions from a file in a given RepositoryCommit. +// CommitStats represents the number of additions / deletions from a file in a given RepositoryCommit or GistCommit. type CommitStats struct { Additions *int `json:"additions,omitempty"` Deletions *int `json:"deletions,omitempty"` @@ -104,7 +104,7 @@ type CommitsListOptions struct { // ListCommits lists the commits of a repository. // // GitHub API docs: http://developer.github.com/v3/repos/commits/#list -func (s *RepositoriesService) ListCommits(owner, repo string, opt *CommitsListOptions) ([]RepositoryCommit, *Response, error) { +func (s *RepositoriesService) ListCommits(owner, repo string, opt *CommitsListOptions) ([]*RepositoryCommit, *Response, error) { u := fmt.Sprintf("repos/%v/%v/commits", owner, repo) u, err := addOptions(u, opt) if err != nil { @@ -116,7 +116,7 @@ func (s *RepositoriesService) ListCommits(owner, repo string, opt *CommitsListOp return nil, nil, err } - commits := new([]RepositoryCommit) + commits := new([]*RepositoryCommit) resp, err := s.client.Do(req, commits) if err != nil { return nil, resp, err @@ -138,6 +138,9 @@ func (s *RepositoriesService) GetCommit(owner, repo, sha string) (*RepositoryCom return nil, nil, err } + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeGitSigningPreview) + commit := new(RepositoryCommit) resp, err := s.client.Do(req, commit) if err != nil { diff --git a/vendor/github.com/google/go-github/github/repos_commits_test.go b/vendor/github.com/google/go-github/github/repos_commits_test.go index 601e7487..771cd9f7 100644 --- a/vendor/github.com/google/go-github/github/repos_commits_test.go +++ b/vendor/github.com/google/go-github/github/repos_commits_test.go @@ -43,7 +43,7 @@ func TestRepositoriesService_ListCommits(t *testing.T) { t.Errorf("Repositories.ListCommits returned error: %v", err) } - want := []RepositoryCommit{{SHA: String("s")}} + want := []*RepositoryCommit{{SHA: String("s")}} if !reflect.DeepEqual(commits, want) { t.Errorf("Repositories.ListCommits returned %+v, want %+v", commits, want) } @@ -55,6 +55,7 @@ func TestRepositoriesService_GetCommit(t *testing.T) { mux.HandleFunc("/repos/o/r/commits/s", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") + testHeader(t, r, "Accept", mediaTypeGitSigningPreview) fmt.Fprintf(w, `{ "sha": "s", "commit": { "message": "m" }, diff --git a/vendor/github.com/google/go-github/github/repos_contents_test.go b/vendor/github.com/google/go-github/github/repos_contents_test.go index 65b917cb..543d8be2 100644 --- a/vendor/github.com/google/go-github/github/repos_contents_test.go +++ b/vendor/github.com/google/go-github/github/repos_contents_test.go @@ -119,24 +119,6 @@ func TestRepositoriesService_GetReadme(t *testing.T) { } } -func ExampleRepositoriesService_GetReadme() { - client := NewClient(nil) - - readme, _, err := client.Repositories.GetReadme("google", "go-github", nil) - if err != nil { - fmt.Println(err) - return - } - - content, err := readme.GetContent() - if err != nil { - fmt.Println(err) - return - } - - fmt.Printf("google/go-github README:\n%v\n", content) -} - func TestRepositoriesService_DownloadContents_Success(t *testing.T) { setup() defer teardown() diff --git a/vendor/github.com/google/go-github/github/repos_deployments.go b/vendor/github.com/google/go-github/github/repos_deployments.go index 214b713b..f3272b06 100644 --- a/vendor/github.com/google/go-github/github/repos_deployments.go +++ b/vendor/github.com/google/go-github/github/repos_deployments.go @@ -61,7 +61,7 @@ type DeploymentsListOptions struct { // ListDeployments lists the deployments of a repository. // // GitHub API docs: https://developer.github.com/v3/repos/deployments/#list-deployments -func (s *RepositoriesService) ListDeployments(owner, repo string, opt *DeploymentsListOptions) ([]Deployment, *Response, error) { +func (s *RepositoriesService) ListDeployments(owner, repo string, opt *DeploymentsListOptions) ([]*Deployment, *Response, error) { u := fmt.Sprintf("repos/%v/%v/deployments", owner, repo) u, err := addOptions(u, opt) if err != nil { @@ -73,7 +73,7 @@ func (s *RepositoriesService) ListDeployments(owner, repo string, opt *Deploymen return nil, nil, err } - deployments := new([]Deployment) + deployments := new([]*Deployment) resp, err := s.client.Do(req, deployments) if err != nil { return nil, resp, err @@ -134,7 +134,7 @@ type DeploymentStatusRequest struct { // ListDeploymentStatuses lists the statuses of a given deployment of a repository. // // GitHub API docs: https://developer.github.com/v3/repos/deployments/#list-deployment-statuses -func (s *RepositoriesService) ListDeploymentStatuses(owner, repo string, deployment int, opt *ListOptions) ([]DeploymentStatus, *Response, error) { +func (s *RepositoriesService) ListDeploymentStatuses(owner, repo string, deployment int, opt *ListOptions) ([]*DeploymentStatus, *Response, error) { u := fmt.Sprintf("repos/%v/%v/deployments/%v/statuses", owner, repo, deployment) u, err := addOptions(u, opt) if err != nil { @@ -146,7 +146,7 @@ func (s *RepositoriesService) ListDeploymentStatuses(owner, repo string, deploym return nil, nil, err } - statuses := new([]DeploymentStatus) + statuses := new([]*DeploymentStatus) resp, err := s.client.Do(req, statuses) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/repos_deployments_test.go b/vendor/github.com/google/go-github/github/repos_deployments_test.go index d11cd3fc..4d777236 100644 --- a/vendor/github.com/google/go-github/github/repos_deployments_test.go +++ b/vendor/github.com/google/go-github/github/repos_deployments_test.go @@ -29,7 +29,7 @@ func TestRepositoriesService_ListDeployments(t *testing.T) { t.Errorf("Repositories.ListDeployments returned error: %v", err) } - want := []Deployment{{ID: Int(1)}, {ID: Int(2)}} + want := []*Deployment{{ID: Int(1)}, {ID: Int(2)}} if !reflect.DeepEqual(deployments, want) { t.Errorf("Repositories.ListDeployments returned %+v, want %+v", deployments, want) } @@ -81,7 +81,7 @@ func TestRepositoriesService_ListDeploymentStatuses(t *testing.T) { t.Errorf("Repositories.ListDeploymentStatuses returned error: %v", err) } - want := []DeploymentStatus{{ID: Int(1)}, {ID: Int(2)}} + want := []*DeploymentStatus{{ID: Int(1)}, {ID: Int(2)}} if !reflect.DeepEqual(statutses, want) { t.Errorf("Repositories.ListDeploymentStatuses returned %+v, want %+v", statutses, want) } diff --git a/vendor/github.com/google/go-github/github/repos_forks.go b/vendor/github.com/google/go-github/github/repos_forks.go index 1fec8292..92e9f27a 100644 --- a/vendor/github.com/google/go-github/github/repos_forks.go +++ b/vendor/github.com/google/go-github/github/repos_forks.go @@ -20,7 +20,7 @@ type RepositoryListForksOptions struct { // ListForks lists the forks of the specified repository. // // GitHub API docs: http://developer.github.com/v3/repos/forks/#list-forks -func (s *RepositoriesService) ListForks(owner, repo string, opt *RepositoryListForksOptions) ([]Repository, *Response, error) { +func (s *RepositoriesService) ListForks(owner, repo string, opt *RepositoryListForksOptions) ([]*Repository, *Response, error) { u := fmt.Sprintf("repos/%v/%v/forks", owner, repo) u, err := addOptions(u, opt) if err != nil { @@ -32,7 +32,7 @@ func (s *RepositoriesService) ListForks(owner, repo string, opt *RepositoryListF return nil, nil, err } - repos := new([]Repository) + repos := new([]*Repository) resp, err := s.client.Do(req, repos) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/repos_forks_test.go b/vendor/github.com/google/go-github/github/repos_forks_test.go index 965a0663..3d2baa54 100644 --- a/vendor/github.com/google/go-github/github/repos_forks_test.go +++ b/vendor/github.com/google/go-github/github/repos_forks_test.go @@ -34,7 +34,7 @@ func TestRepositoriesService_ListForks(t *testing.T) { t.Errorf("Repositories.ListForks returned error: %v", err) } - want := []Repository{{ID: Int(1)}, {ID: Int(2)}} + want := []*Repository{{ID: Int(1)}, {ID: Int(2)}} if !reflect.DeepEqual(repos, want) { t.Errorf("Repositories.ListForks returned %+v, want %+v", repos, want) } diff --git a/vendor/github.com/google/go-github/github/repos_hooks.go b/vendor/github.com/google/go-github/github/repos_hooks.go index 4370c160..fe725b45 100644 --- a/vendor/github.com/google/go-github/github/repos_hooks.go +++ b/vendor/github.com/google/go-github/github/repos_hooks.go @@ -105,7 +105,7 @@ func (s *RepositoriesService) CreateHook(owner, repo string, hook *Hook) (*Hook, // ListHooks lists all Hooks for the specified repository. // // GitHub API docs: http://developer.github.com/v3/repos/hooks/#list -func (s *RepositoriesService) ListHooks(owner, repo string, opt *ListOptions) ([]Hook, *Response, error) { +func (s *RepositoriesService) ListHooks(owner, repo string, opt *ListOptions) ([]*Hook, *Response, error) { u := fmt.Sprintf("repos/%v/%v/hooks", owner, repo) u, err := addOptions(u, opt) if err != nil { @@ -117,7 +117,7 @@ func (s *RepositoriesService) ListHooks(owner, repo string, opt *ListOptions) ([ return nil, nil, err } - hooks := new([]Hook) + hooks := new([]*Hook) resp, err := s.client.Do(req, hooks) if err != nil { return nil, resp, err @@ -191,6 +191,6 @@ func (s *RepositoriesService) TestHook(owner, repo string, id int) (*Response, e } // ListServiceHooks is deprecated. Use Client.ListServiceHooks instead. -func (s *RepositoriesService) ListServiceHooks() ([]ServiceHook, *Response, error) { +func (s *RepositoriesService) ListServiceHooks() ([]*ServiceHook, *Response, error) { return s.client.ListServiceHooks() } diff --git a/vendor/github.com/google/go-github/github/repos_hooks_test.go b/vendor/github.com/google/go-github/github/repos_hooks_test.go index c163a26b..fcfc9a7f 100644 --- a/vendor/github.com/google/go-github/github/repos_hooks_test.go +++ b/vendor/github.com/google/go-github/github/repos_hooks_test.go @@ -64,7 +64,7 @@ func TestRepositoriesService_ListHooks(t *testing.T) { t.Errorf("Repositories.ListHooks returned error: %v", err) } - want := []Hook{{ID: Int(1)}, {ID: Int(2)}} + want := []*Hook{{ID: Int(1)}, {ID: Int(2)}} if !reflect.DeepEqual(hooks, want) { t.Errorf("Repositories.ListHooks returned %+v, want %+v", hooks, want) } diff --git a/vendor/github.com/google/go-github/github/repos_invitations.go b/vendor/github.com/google/go-github/github/repos_invitations.go new file mode 100644 index 00000000..f2806d11 --- /dev/null +++ b/vendor/github.com/google/go-github/github/repos_invitations.go @@ -0,0 +1,91 @@ +// Copyright 2016 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import "fmt" + +// RepositoryInvitation represents an invitation to collaborate on a repo. +type RepositoryInvitation struct { + ID *int `json:"id,omitempty"` + Repo *Repository `json:"repository,omitempty"` + Invitee *User `json:"invitee,omitempty"` + Inviter *User `json:"inviter,omitempty"` + + // Permissions represents the permissions that the associated user will have + // on the repository. Possible values are: "read", "write", "admin". + Permissions *string `json:"permissions,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + URL *string `json:"url,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` +} + +// ListInvitations lists all currently-open repository invitations. +// +// GitHub API docs: https://developer.github.com/v3/repos/invitations/#list-invitations-for-a-repository +func (s *RepositoriesService) ListInvitations(repoID int, opt *ListOptions) ([]*RepositoryInvitation, *Response, error) { + u := fmt.Sprintf("repositories/%v/invitations", repoID) + u, err := addOptions(u, opt) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeRepositoryInvitationsPreview) + + invites := []*RepositoryInvitation{} + resp, err := s.client.Do(req, &invites) + if err != nil { + return nil, resp, err + } + + return invites, resp, err +} + +// DeleteInvitation deletes a repository invitation. +// +// GitHub API docs: https://developer.github.com/v3/repos/invitations/#delete-a-repository-invitation +func (s *RepositoriesService) DeleteInvitation(repoID, invitationID int) (*Response, error) { + u := fmt.Sprintf("repositories/%v/invitations/%v", repoID, invitationID) + req, err := s.client.NewRequest("DELETE", u, nil) + if err != nil { + return nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeRepositoryInvitationsPreview) + + return s.client.Do(req, nil) +} + +// UpdateInvitation updates the permissions associated with a repository +// invitation. +// +// permissions represents the permissions that the associated user will have +// on the repository. Possible values are: "read", "write", "admin". +// +// GitHub API docs: https://developer.github.com/v3/repos/invitations/#update-a-repository-invitation +func (s *RepositoriesService) UpdateInvitation(repoID, invitationID int, permissions string) (*RepositoryInvitation, *Response, error) { + opts := &struct { + Permissions string `json:"permissions"` + }{Permissions: permissions} + u := fmt.Sprintf("repositories/%v/invitations/%v", repoID, invitationID) + req, err := s.client.NewRequest("PATCH", u, opts) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeRepositoryInvitationsPreview) + + invite := &RepositoryInvitation{} + resp, err := s.client.Do(req, invite) + return invite, resp, err +} diff --git a/vendor/github.com/google/go-github/github/repos_invitations_test.go b/vendor/github.com/google/go-github/github/repos_invitations_test.go new file mode 100644 index 00000000..c5688cb6 --- /dev/null +++ b/vendor/github.com/google/go-github/github/repos_invitations_test.go @@ -0,0 +1,73 @@ +// Copyright 2016 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "fmt" + "net/http" + "reflect" + "testing" +) + +func TestRepositoriesService_ListInvitations(t *testing.T) { + setup() + defer teardown() + + mux.HandleFunc("/repositories/1/invitations", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testHeader(t, r, "Accept", mediaTypeRepositoryInvitationsPreview) + testFormValues(t, r, values{"page": "2"}) + fmt.Fprintf(w, `[{"id":1}, {"id":2}]`) + }) + + opt := &ListOptions{Page: 2} + got, _, err := client.Repositories.ListInvitations(1, opt) + if err != nil { + t.Errorf("Repositories.ListInvitations returned error: %v", err) + } + + want := []*RepositoryInvitation{{ID: Int(1)}, {ID: Int(2)}} + if !reflect.DeepEqual(got, want) { + t.Errorf("Repositories.ListInvitations = %+v, want %+v", got, want) + } +} + +func TestRepositoriesService_DeleteInvitation(t *testing.T) { + setup() + defer teardown() + + mux.HandleFunc("/repositories/1/invitations/2", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "DELETE") + testHeader(t, r, "Accept", mediaTypeRepositoryInvitationsPreview) + w.WriteHeader(http.StatusNoContent) + }) + + _, err := client.Repositories.DeleteInvitation(1, 2) + if err != nil { + t.Errorf("Repositories.DeleteInvitation returned error: %v", err) + } +} + +func TestRepositoriesService_UpdateInvitation(t *testing.T) { + setup() + defer teardown() + + mux.HandleFunc("/repositories/1/invitations/2", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "PATCH") + testHeader(t, r, "Accept", mediaTypeRepositoryInvitationsPreview) + fmt.Fprintf(w, `{"id":1}`) + }) + + got, _, err := client.Repositories.UpdateInvitation(1, 2, "write") + if err != nil { + t.Errorf("Repositories.UpdateInvitation returned error: %v", err) + } + + want := &RepositoryInvitation{ID: Int(1)} + if !reflect.DeepEqual(got, want) { + t.Errorf("Repositories.UpdateInvitation = %+v, want %+v", got, want) + } +} diff --git a/vendor/github.com/google/go-github/github/repos_keys.go b/vendor/github.com/google/go-github/github/repos_keys.go index 0d12ec9a..0bb404a3 100644 --- a/vendor/github.com/google/go-github/github/repos_keys.go +++ b/vendor/github.com/google/go-github/github/repos_keys.go @@ -12,7 +12,7 @@ import "fmt" // ListKeys lists the deploy keys for a repository. // // GitHub API docs: http://developer.github.com/v3/repos/keys/#list -func (s *RepositoriesService) ListKeys(owner string, repo string, opt *ListOptions) ([]Key, *Response, error) { +func (s *RepositoriesService) ListKeys(owner string, repo string, opt *ListOptions) ([]*Key, *Response, error) { u := fmt.Sprintf("repos/%v/%v/keys", owner, repo) u, err := addOptions(u, opt) if err != nil { @@ -24,7 +24,7 @@ func (s *RepositoriesService) ListKeys(owner string, repo string, opt *ListOptio return nil, nil, err } - keys := new([]Key) + keys := new([]*Key) resp, err := s.client.Do(req, keys) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/repos_keys_test.go b/vendor/github.com/google/go-github/github/repos_keys_test.go index dcf6c55e..3bea308f 100644 --- a/vendor/github.com/google/go-github/github/repos_keys_test.go +++ b/vendor/github.com/google/go-github/github/repos_keys_test.go @@ -29,7 +29,7 @@ func TestRepositoriesService_ListKeys(t *testing.T) { t.Errorf("Repositories.ListKeys returned error: %v", err) } - want := []Key{{ID: Int(1)}} + want := []*Key{{ID: Int(1)}} if !reflect.DeepEqual(keys, want) { t.Errorf("Repositories.ListKeys returned %+v, want %+v", keys, want) } diff --git a/vendor/github.com/google/go-github/github/repos_pages.go b/vendor/github.com/google/go-github/github/repos_pages.go index 2384eaf6..8594edc5 100644 --- a/vendor/github.com/google/go-github/github/repos_pages.go +++ b/vendor/github.com/google/go-github/github/repos_pages.go @@ -54,14 +54,14 @@ func (s *RepositoriesService) GetPagesInfo(owner string, repo string) (*Pages, * // ListPagesBuilds lists the builds for a GitHub Pages site. // // GitHub API docs: https://developer.github.com/v3/repos/pages/#list-pages-builds -func (s *RepositoriesService) ListPagesBuilds(owner string, repo string) ([]PagesBuild, *Response, error) { +func (s *RepositoriesService) ListPagesBuilds(owner string, repo string) ([]*PagesBuild, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pages/builds", owner, repo) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err } - var pages []PagesBuild + var pages []*PagesBuild resp, err := s.client.Do(req, &pages) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/repos_pages_test.go b/vendor/github.com/google/go-github/github/repos_pages_test.go index 4cbc43a1..2bfd8f61 100644 --- a/vendor/github.com/google/go-github/github/repos_pages_test.go +++ b/vendor/github.com/google/go-github/github/repos_pages_test.go @@ -46,7 +46,7 @@ func TestRepositoriesService_ListPagesBuilds(t *testing.T) { t.Errorf("Repositories.ListPagesBuilds returned error: %v", err) } - want := []PagesBuild{{URL: String("u"), Status: String("s"), Commit: String("c")}} + want := []*PagesBuild{{URL: String("u"), Status: String("s"), Commit: String("c")}} if !reflect.DeepEqual(pages, want) { t.Errorf("Repositories.ListPagesBuilds returned %+v, want %+v", pages, want) } diff --git a/vendor/github.com/google/go-github/github/repos_releases.go b/vendor/github.com/google/go-github/github/repos_releases.go index 37e356ad..e889b0d5 100644 --- a/vendor/github.com/google/go-github/github/repos_releases.go +++ b/vendor/github.com/google/go-github/github/repos_releases.go @@ -64,7 +64,7 @@ func (r ReleaseAsset) String() string { // ListReleases lists the releases for a repository. // // GitHub API docs: http://developer.github.com/v3/repos/releases/#list-releases-for-a-repository -func (s *RepositoriesService) ListReleases(owner, repo string, opt *ListOptions) ([]RepositoryRelease, *Response, error) { +func (s *RepositoriesService) ListReleases(owner, repo string, opt *ListOptions) ([]*RepositoryRelease, *Response, error) { u := fmt.Sprintf("repos/%s/%s/releases", owner, repo) u, err := addOptions(u, opt) if err != nil { @@ -76,7 +76,7 @@ func (s *RepositoriesService) ListReleases(owner, repo string, opt *ListOptions) return nil, nil, err } - releases := new([]RepositoryRelease) + releases := new([]*RepositoryRelease) resp, err := s.client.Do(req, releases) if err != nil { return nil, resp, err @@ -176,7 +176,7 @@ func (s *RepositoriesService) DeleteRelease(owner, repo string, id int) (*Respon // ListReleaseAssets lists the release's assets. // // GitHub API docs : http://developer.github.com/v3/repos/releases/#list-assets-for-a-release -func (s *RepositoriesService) ListReleaseAssets(owner, repo string, id int, opt *ListOptions) ([]ReleaseAsset, *Response, error) { +func (s *RepositoriesService) ListReleaseAssets(owner, repo string, id int, opt *ListOptions) ([]*ReleaseAsset, *Response, error) { u := fmt.Sprintf("repos/%s/%s/releases/%d/assets", owner, repo, id) u, err := addOptions(u, opt) if err != nil { @@ -188,7 +188,7 @@ func (s *RepositoriesService) ListReleaseAssets(owner, repo string, id int, opt return nil, nil, err } - assets := new([]ReleaseAsset) + assets := new([]*ReleaseAsset) resp, err := s.client.Do(req, assets) if err != nil { return nil, resp, nil diff --git a/vendor/github.com/google/go-github/github/repos_releases_test.go b/vendor/github.com/google/go-github/github/repos_releases_test.go index 0151fcda..412b2453 100644 --- a/vendor/github.com/google/go-github/github/repos_releases_test.go +++ b/vendor/github.com/google/go-github/github/repos_releases_test.go @@ -32,7 +32,7 @@ func TestRepositoriesService_ListReleases(t *testing.T) { if err != nil { t.Errorf("Repositories.ListReleases returned error: %v", err) } - want := []RepositoryRelease{{ID: Int(1)}} + want := []*RepositoryRelease{{ID: Int(1)}} if !reflect.DeepEqual(releases, want) { t.Errorf("Repositories.ListReleases returned %+v, want %+v", releases, want) } @@ -182,7 +182,7 @@ func TestRepositoriesService_ListReleaseAssets(t *testing.T) { if err != nil { t.Errorf("Repositories.ListReleaseAssets returned error: %v", err) } - want := []ReleaseAsset{{ID: Int(1)}} + want := []*ReleaseAsset{{ID: Int(1)}} if !reflect.DeepEqual(assets, want) { t.Errorf("Repositories.ListReleaseAssets returned %+v, want %+v", assets, want) } diff --git a/vendor/github.com/google/go-github/github/repos_stats.go b/vendor/github.com/google/go-github/github/repos_stats.go index 3474b550..e4f75a5b 100644 --- a/vendor/github.com/google/go-github/github/repos_stats.go +++ b/vendor/github.com/google/go-github/github/repos_stats.go @@ -45,14 +45,14 @@ func (w WeeklyStats) String() string { // delay of a second or so, should result in a successful request. // // GitHub API Docs: https://developer.github.com/v3/repos/statistics/#contributors -func (s *RepositoriesService) ListContributorsStats(owner, repo string) ([]ContributorStats, *Response, error) { +func (s *RepositoriesService) ListContributorsStats(owner, repo string) ([]*ContributorStats, *Response, error) { u := fmt.Sprintf("repos/%v/%v/stats/contributors", owner, repo) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err } - var contributorStats []ContributorStats + var contributorStats []*ContributorStats resp, err := s.client.Do(req, &contributorStats) if err != nil { return nil, resp, err @@ -84,14 +84,14 @@ func (w WeeklyCommitActivity) String() string { // delay of a second or so, should result in a successful request. // // GitHub API Docs: https://developer.github.com/v3/repos/statistics/#commit-activity -func (s *RepositoriesService) ListCommitActivity(owner, repo string) ([]WeeklyCommitActivity, *Response, error) { +func (s *RepositoriesService) ListCommitActivity(owner, repo string) ([]*WeeklyCommitActivity, *Response, error) { u := fmt.Sprintf("repos/%v/%v/stats/commit_activity", owner, repo) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err } - var weeklyCommitActivity []WeeklyCommitActivity + var weeklyCommitActivity []*WeeklyCommitActivity resp, err := s.client.Do(req, &weeklyCommitActivity) if err != nil { return nil, resp, err @@ -105,7 +105,7 @@ func (s *RepositoriesService) ListCommitActivity(owner, repo string) ([]WeeklyCo // additions and deletions, but not total commits. // // GitHub API Docs: https://developer.github.com/v3/repos/statistics/#code-frequency -func (s *RepositoriesService) ListCodeFrequency(owner, repo string) ([]WeeklyStats, *Response, error) { +func (s *RepositoriesService) ListCodeFrequency(owner, repo string) ([]*WeeklyStats, *Response, error) { u := fmt.Sprintf("repos/%v/%v/stats/code_frequency", owner, repo) req, err := s.client.NewRequest("GET", u, nil) if err != nil { @@ -116,12 +116,12 @@ func (s *RepositoriesService) ListCodeFrequency(owner, repo string) ([]WeeklySta resp, err := s.client.Do(req, &weeks) // convert int slices into WeeklyStats - var stats []WeeklyStats + var stats []*WeeklyStats for _, week := range weeks { if len(week) != 3 { continue } - stat := WeeklyStats{ + stat := &WeeklyStats{ Week: &Timestamp{time.Unix(int64(week[0]), 0)}, Additions: Int(week[1]), Deletions: Int(week[2]), @@ -186,7 +186,7 @@ type PunchCard struct { // ListPunchCard returns the number of commits per hour in each day. // // GitHub API Docs: https://developer.github.com/v3/repos/statistics/#punch-card -func (s *RepositoriesService) ListPunchCard(owner, repo string) ([]PunchCard, *Response, error) { +func (s *RepositoriesService) ListPunchCard(owner, repo string) ([]*PunchCard, *Response, error) { u := fmt.Sprintf("repos/%v/%v/stats/punch_card", owner, repo) req, err := s.client.NewRequest("GET", u, nil) if err != nil { @@ -197,12 +197,12 @@ func (s *RepositoriesService) ListPunchCard(owner, repo string) ([]PunchCard, *R resp, err := s.client.Do(req, &results) // convert int slices into Punchcards - var cards []PunchCard + var cards []*PunchCard for _, result := range results { if len(result) != 3 { continue } - card := PunchCard{ + card := &PunchCard{ Day: Int(result[0]), Hour: Int(result[1]), Commits: Int(result[2]), diff --git a/vendor/github.com/google/go-github/github/repos_stats_test.go b/vendor/github.com/google/go-github/github/repos_stats_test.go index 3f9fab5c..56acc56f 100644 --- a/vendor/github.com/google/go-github/github/repos_stats_test.go +++ b/vendor/github.com/google/go-github/github/repos_stats_test.go @@ -45,7 +45,7 @@ func TestRepositoriesService_ListContributorsStats(t *testing.T) { t.Errorf("RepositoriesService.ListContributorsStats returned error: %v", err) } - want := []ContributorStats{ + want := []*ContributorStats{ { Author: &Contributor{ ID: Int(1), @@ -90,7 +90,7 @@ func TestRepositoriesService_ListCommitActivity(t *testing.T) { t.Errorf("RepositoriesService.ListCommitActivity returned error: %v", err) } - want := []WeeklyCommitActivity{ + want := []*WeeklyCommitActivity{ { Days: []int{0, 3, 26, 20, 39, 1, 0}, Total: Int(89), @@ -118,7 +118,7 @@ func TestRepositoriesService_ListCodeFrequency(t *testing.T) { t.Errorf("RepositoriesService.ListCodeFrequency returned error: %v", err) } - want := []WeeklyStats{{ + want := []*WeeklyStats{{ Week: &Timestamp{time.Date(2011, 04, 17, 00, 00, 00, 0, time.UTC).Local()}, Additions: Int(1124), Deletions: Int(-435), @@ -198,7 +198,7 @@ func TestRepositoriesService_ListPunchCard(t *testing.T) { t.Errorf("RepositoriesService.ListPunchCard returned error: %v", err) } - want := []PunchCard{ + want := []*PunchCard{ {Day: Int(0), Hour: Int(0), Commits: Int(5)}, {Day: Int(0), Hour: Int(1), Commits: Int(43)}, {Day: Int(0), Hour: Int(2), Commits: Int(21)}, diff --git a/vendor/github.com/google/go-github/github/repos_statuses.go b/vendor/github.com/google/go-github/github/repos_statuses.go index 7a6ee7c6..6478ee2a 100644 --- a/vendor/github.com/google/go-github/github/repos_statuses.go +++ b/vendor/github.com/google/go-github/github/repos_statuses.go @@ -42,7 +42,7 @@ func (r RepoStatus) String() string { // reference. ref can be a SHA, a branch name, or a tag name. // // GitHub API docs: http://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref -func (s *RepositoriesService) ListStatuses(owner, repo, ref string, opt *ListOptions) ([]RepoStatus, *Response, error) { +func (s *RepositoriesService) ListStatuses(owner, repo, ref string, opt *ListOptions) ([]*RepoStatus, *Response, error) { u := fmt.Sprintf("repos/%v/%v/commits/%v/statuses", owner, repo, ref) u, err := addOptions(u, opt) if err != nil { @@ -54,7 +54,7 @@ func (s *RepositoriesService) ListStatuses(owner, repo, ref string, opt *ListOpt return nil, nil, err } - statuses := new([]RepoStatus) + statuses := new([]*RepoStatus) resp, err := s.client.Do(req, statuses) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/repos_statuses_test.go b/vendor/github.com/google/go-github/github/repos_statuses_test.go index 8b230528..c1cfc12e 100644 --- a/vendor/github.com/google/go-github/github/repos_statuses_test.go +++ b/vendor/github.com/google/go-github/github/repos_statuses_test.go @@ -29,7 +29,7 @@ func TestRepositoriesService_ListStatuses(t *testing.T) { t.Errorf("Repositories.ListStatuses returned error: %v", err) } - want := []RepoStatus{{ID: Int(1)}} + want := []*RepoStatus{{ID: Int(1)}} if !reflect.DeepEqual(statuses, want) { t.Errorf("Repositories.ListStatuses returned %+v, want %+v", statuses, want) } diff --git a/vendor/github.com/google/go-github/github/repos_test.go b/vendor/github.com/google/go-github/github/repos_test.go index c864aff2..9f738f90 100644 --- a/vendor/github.com/google/go-github/github/repos_test.go +++ b/vendor/github.com/google/go-github/github/repos_test.go @@ -28,7 +28,7 @@ func TestRepositoriesService_List_authenticatedUser(t *testing.T) { t.Errorf("Repositories.List returned error: %v", err) } - want := []Repository{{ID: Int(1)}, {ID: Int(2)}} + want := []*Repository{{ID: Int(1)}, {ID: Int(2)}} if !reflect.DeepEqual(repos, want) { t.Errorf("Repositories.List returned %+v, want %+v", repos, want) } @@ -42,21 +42,55 @@ func TestRepositoriesService_List_specifiedUser(t *testing.T) { testMethod(t, r, "GET") testHeader(t, r, "Accept", mediaTypeLicensesPreview) testFormValues(t, r, values{ - "type": "owner", - "sort": "created", - "direction": "asc", - "page": "2", + "visibility": "public", + "affiliation": "owner,collaborator", + "sort": "created", + "direction": "asc", + "page": "2", }) fmt.Fprint(w, `[{"id":1}]`) }) - opt := &RepositoryListOptions{"owner", "created", "asc", ListOptions{Page: 2}} + opt := &RepositoryListOptions{ + Visibility: "public", + Affiliation: "owner,collaborator", + Sort: "created", + Direction: "asc", + ListOptions: ListOptions{Page: 2}, + } repos, _, err := client.Repositories.List("u", opt) if err != nil { t.Errorf("Repositories.List returned error: %v", err) } - want := []Repository{{ID: Int(1)}} + want := []*Repository{{ID: Int(1)}} + if !reflect.DeepEqual(repos, want) { + t.Errorf("Repositories.List returned %+v, want %+v", repos, want) + } +} + +func TestRepositoriesService_List_specifiedUser_type(t *testing.T) { + setup() + defer teardown() + + mux.HandleFunc("/users/u/repos", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testHeader(t, r, "Accept", mediaTypeLicensesPreview) + testFormValues(t, r, values{ + "type": "owner", + }) + fmt.Fprint(w, `[{"id":1}]`) + }) + + opt := &RepositoryListOptions{ + Type: "owner", + } + repos, _, err := client.Repositories.List("u", opt) + if err != nil { + t.Errorf("Repositories.List returned error: %v", err) + } + + want := []*Repository{{ID: Int(1)}} if !reflect.DeepEqual(repos, want) { t.Errorf("Repositories.List returned %+v, want %+v", repos, want) } @@ -67,20 +101,6 @@ func TestRepositoriesService_List_invalidUser(t *testing.T) { testURLParseError(t, err) } -func ExampleRepositoriesService_List() { - client := NewClient(nil) - - user := "willnorris" - opt := &RepositoryListOptions{Type: "owner", Sort: "updated", Direction: "desc"} - - repos, _, err := client.Repositories.List(user, opt) - if err != nil { - fmt.Println(err) - } - - fmt.Printf("Recently updated repositories by %q: %v", user, Stringify(repos)) -} - func TestRepositoriesService_ListByOrg(t *testing.T) { setup() defer teardown() @@ -101,7 +121,7 @@ func TestRepositoriesService_ListByOrg(t *testing.T) { t.Errorf("Repositories.ListByOrg returned error: %v", err) } - want := []Repository{{ID: Int(1)}} + want := []*Repository{{ID: Int(1)}} if !reflect.DeepEqual(repos, want) { t.Errorf("Repositories.ListByOrg returned %+v, want %+v", repos, want) } @@ -132,7 +152,7 @@ func TestRepositoriesService_ListAll(t *testing.T) { t.Errorf("Repositories.ListAll returned error: %v", err) } - want := []Repository{{ID: Int(1)}} + want := []*Repository{{ID: Int(1)}} if !reflect.DeepEqual(repos, want) { t.Errorf("Repositories.ListAll returned %+v, want %+v", repos, want) } @@ -311,12 +331,11 @@ func TestRepositoriesService_ListContributors(t *testing.T) { opts := &ListContributorsOptions{Anon: "true", ListOptions: ListOptions{Page: 2}} contributors, _, err := client.Repositories.ListContributors("o", "r", opts) - if err != nil { t.Errorf("Repositories.ListContributors returned error: %v", err) } - want := []Contributor{{Contributions: Int(42)}} + want := []*Contributor{{Contributions: Int(42)}} if !reflect.DeepEqual(contributors, want) { t.Errorf("Repositories.ListContributors returned %+v, want %+v", contributors, want) } @@ -358,7 +377,7 @@ func TestRepositoriesService_ListTeams(t *testing.T) { t.Errorf("Repositories.ListTeams returned error: %v", err) } - want := []Team{{ID: Int(1)}} + want := []*Team{{ID: Int(1)}} if !reflect.DeepEqual(teams, want) { t.Errorf("Repositories.ListTeams returned %+v, want %+v", teams, want) } @@ -380,7 +399,7 @@ func TestRepositoriesService_ListTags(t *testing.T) { t.Errorf("Repositories.ListTags returned error: %v", err) } - want := []RepositoryTag{ + want := []*RepositoryTag{ { Name: String("n"), Commit: &Commit{ @@ -413,7 +432,7 @@ func TestRepositoriesService_ListBranches(t *testing.T) { t.Errorf("Repositories.ListBranches returned error: %v", err) } - want := []Branch{{Name: String("master"), Commit: &Commit{SHA: String("a57781"), URL: String("https://api.github.com/repos/o/r/commits/a57781")}}} + want := []*Branch{{Name: String("master"), Commit: &Commit{SHA: String("a57781"), URL: String("https://api.github.com/repos/o/r/commits/a57781")}}} if !reflect.DeepEqual(branches, want) { t.Errorf("Repositories.ListBranches returned %+v, want %+v", branches, want) } diff --git a/vendor/github.com/google/go-github/github/users.go b/vendor/github.com/google/go-github/github/users.go index 0312724e..17208041 100644 --- a/vendor/github.com/google/go-github/github/users.go +++ b/vendor/github.com/google/go-github/github/users.go @@ -138,12 +138,16 @@ func (s *UsersService) Edit(user *User) (*User, *Response, error) { type UserListOptions struct { // ID of the last user seen Since int `url:"since,omitempty"` + + ListOptions } // ListAll lists all GitHub users. // +// To paginate through all users, populate 'Since' with the ID of the last user. +// // GitHub API docs: http://developer.github.com/v3/users/#get-all-users -func (s *UsersService) ListAll(opt *UserListOptions) ([]User, *Response, error) { +func (s *UsersService) ListAll(opt *UserListOptions) ([]*User, *Response, error) { u, err := addOptions("users", opt) if err != nil { return nil, nil, err @@ -154,7 +158,7 @@ func (s *UsersService) ListAll(opt *UserListOptions) ([]User, *Response, error) return nil, nil, err } - users := new([]User) + users := new([]*User) resp, err := s.client.Do(req, users) if err != nil { return nil, resp, err @@ -162,3 +166,59 @@ func (s *UsersService) ListAll(opt *UserListOptions) ([]User, *Response, error) return *users, resp, err } + +// ListInvitations lists all currently-open repository invitations for the +// authenticated user. +// +// GitHub API docs: https://developer.github.com/v3/repos/invitations/#list-a-users-repository-invitations +func (s *UsersService) ListInvitations() ([]*RepositoryInvitation, *Response, error) { + req, err := s.client.NewRequest("GET", "user/repository_invitations", nil) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeRepositoryInvitationsPreview) + + invites := []*RepositoryInvitation{} + resp, err := s.client.Do(req, &invites) + if err != nil { + return nil, resp, err + } + + return invites, resp, err +} + +// AcceptInvitation accepts the currently-open repository invitation for the +// authenticated user. +// +// GitHub API docs: https://developer.github.com/v3/repos/invitations/#accept-a-repository-invitation +func (s *UsersService) AcceptInvitation(invitationID int) (*Response, error) { + u := fmt.Sprintf("user/repository_invitations/%v", invitationID) + req, err := s.client.NewRequest("PATCH", u, nil) + if err != nil { + return nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeRepositoryInvitationsPreview) + + return s.client.Do(req, nil) +} + +// DeclineInvitation declines the currently-open repository invitation for the +// authenticated user. +// +// GitHub API docs: https://developer.github.com/v3/repos/invitations/#decline-a-repository-invitation +func (s *UsersService) DeclineInvitation(invitationID int) (*Response, error) { + u := fmt.Sprintf("user/repository_invitations/%v", invitationID) + req, err := s.client.NewRequest("DELETE", u, nil) + if err != nil { + return nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeRepositoryInvitationsPreview) + + return s.client.Do(req, nil) +} diff --git a/vendor/github.com/google/go-github/github/users_emails.go b/vendor/github.com/google/go-github/github/users_emails.go index 75531912..e4a58983 100644 --- a/vendor/github.com/google/go-github/github/users_emails.go +++ b/vendor/github.com/google/go-github/github/users_emails.go @@ -15,7 +15,7 @@ type UserEmail struct { // ListEmails lists all email addresses for the authenticated user. // // GitHub API docs: http://developer.github.com/v3/users/emails/#list-email-addresses-for-a-user -func (s *UsersService) ListEmails(opt *ListOptions) ([]UserEmail, *Response, error) { +func (s *UsersService) ListEmails(opt *ListOptions) ([]*UserEmail, *Response, error) { u := "user/emails" u, err := addOptions(u, opt) if err != nil { @@ -27,7 +27,7 @@ func (s *UsersService) ListEmails(opt *ListOptions) ([]UserEmail, *Response, err return nil, nil, err } - emails := new([]UserEmail) + emails := new([]*UserEmail) resp, err := s.client.Do(req, emails) if err != nil { return nil, resp, err @@ -39,14 +39,14 @@ func (s *UsersService) ListEmails(opt *ListOptions) ([]UserEmail, *Response, err // AddEmails adds email addresses of the authenticated user. // // GitHub API docs: http://developer.github.com/v3/users/emails/#add-email-addresses -func (s *UsersService) AddEmails(emails []string) ([]UserEmail, *Response, error) { +func (s *UsersService) AddEmails(emails []string) ([]*UserEmail, *Response, error) { u := "user/emails" req, err := s.client.NewRequest("POST", u, emails) if err != nil { return nil, nil, err } - e := new([]UserEmail) + e := new([]*UserEmail) resp, err := s.client.Do(req, e) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/users_emails_test.go b/vendor/github.com/google/go-github/github/users_emails_test.go index 7eb65086..13a444fe 100644 --- a/vendor/github.com/google/go-github/github/users_emails_test.go +++ b/vendor/github.com/google/go-github/github/users_emails_test.go @@ -33,7 +33,7 @@ func TestUsersService_ListEmails(t *testing.T) { t.Errorf("Users.ListEmails returned error: %v", err) } - want := []UserEmail{{Email: String("user@example.com"), Verified: Bool(false), Primary: Bool(true)}} + want := []*UserEmail{{Email: String("user@example.com"), Verified: Bool(false), Primary: Bool(true)}} if !reflect.DeepEqual(emails, want) { t.Errorf("Users.ListEmails returned %+v, want %+v", emails, want) } @@ -62,7 +62,7 @@ func TestUsersService_AddEmails(t *testing.T) { t.Errorf("Users.AddEmails returned error: %v", err) } - want := []UserEmail{ + want := []*UserEmail{ {Email: String("old@example.com")}, {Email: String("new@example.com")}, } diff --git a/vendor/github.com/google/go-github/github/users_followers.go b/vendor/github.com/google/go-github/github/users_followers.go index 7ecbed9f..38a16621 100644 --- a/vendor/github.com/google/go-github/github/users_followers.go +++ b/vendor/github.com/google/go-github/github/users_followers.go @@ -11,7 +11,7 @@ import "fmt" // fetch followers for the authenticated user. // // GitHub API docs: http://developer.github.com/v3/users/followers/#list-followers-of-a-user -func (s *UsersService) ListFollowers(user string, opt *ListOptions) ([]User, *Response, error) { +func (s *UsersService) ListFollowers(user string, opt *ListOptions) ([]*User, *Response, error) { var u string if user != "" { u = fmt.Sprintf("users/%v/followers", user) @@ -28,7 +28,7 @@ func (s *UsersService) ListFollowers(user string, opt *ListOptions) ([]User, *Re return nil, nil, err } - users := new([]User) + users := new([]*User) resp, err := s.client.Do(req, users) if err != nil { return nil, resp, err @@ -41,7 +41,7 @@ func (s *UsersService) ListFollowers(user string, opt *ListOptions) ([]User, *Re // string will list people the authenticated user is following. // // GitHub API docs: http://developer.github.com/v3/users/followers/#list-users-followed-by-another-user -func (s *UsersService) ListFollowing(user string, opt *ListOptions) ([]User, *Response, error) { +func (s *UsersService) ListFollowing(user string, opt *ListOptions) ([]*User, *Response, error) { var u string if user != "" { u = fmt.Sprintf("users/%v/following", user) @@ -58,7 +58,7 @@ func (s *UsersService) ListFollowing(user string, opt *ListOptions) ([]User, *Re return nil, nil, err } - users := new([]User) + users := new([]*User) resp, err := s.client.Do(req, users) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/users_followers_test.go b/vendor/github.com/google/go-github/github/users_followers_test.go index f4d24578..04477216 100644 --- a/vendor/github.com/google/go-github/github/users_followers_test.go +++ b/vendor/github.com/google/go-github/github/users_followers_test.go @@ -28,7 +28,7 @@ func TestUsersService_ListFollowers_authenticatedUser(t *testing.T) { t.Errorf("Users.ListFollowers returned error: %v", err) } - want := []User{{ID: Int(1)}} + want := []*User{{ID: Int(1)}} if !reflect.DeepEqual(users, want) { t.Errorf("Users.ListFollowers returned %+v, want %+v", users, want) } @@ -48,7 +48,7 @@ func TestUsersService_ListFollowers_specifiedUser(t *testing.T) { t.Errorf("Users.ListFollowers returned error: %v", err) } - want := []User{{ID: Int(1)}} + want := []*User{{ID: Int(1)}} if !reflect.DeepEqual(users, want) { t.Errorf("Users.ListFollowers returned %+v, want %+v", users, want) } @@ -75,7 +75,7 @@ func TestUsersService_ListFollowing_authenticatedUser(t *testing.T) { t.Errorf("Users.ListFollowing returned error: %v", err) } - want := []User{{ID: Int(1)}} + want := []*User{{ID: Int(1)}} if !reflect.DeepEqual(users, want) { t.Errorf("Users.ListFollowing returned %+v, want %+v", users, want) } @@ -95,7 +95,7 @@ func TestUsersService_ListFollowing_specifiedUser(t *testing.T) { t.Errorf("Users.ListFollowing returned error: %v", err) } - want := []User{{ID: Int(1)}} + want := []*User{{ID: Int(1)}} if !reflect.DeepEqual(users, want) { t.Errorf("Users.ListFollowing returned %+v, want %+v", users, want) } diff --git a/vendor/github.com/google/go-github/github/users_gpg_keys.go b/vendor/github.com/google/go-github/github/users_gpg_keys.go new file mode 100644 index 00000000..08cfbed5 --- /dev/null +++ b/vendor/github.com/google/go-github/github/users_gpg_keys.go @@ -0,0 +1,127 @@ +// Copyright 2016 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "fmt" + "time" +) + +// GPGKey represents a GitHub user's public GPG key used to verify GPG signed commits and tags. +// +// https://developer.github.com/changes/2016-04-04-git-signing-api-preview/ +type GPGKey struct { + ID *int `json:"id,omitempty"` + PrimaryKeyID *int `json:"primary_key_id,omitempty"` + KeyID *string `json:"key_id,omitempty"` + PublicKey *string `json:"public_key,omitempty"` + Emails []GPGEmail `json:"emails,omitempty"` + Subkeys []GPGKey `json:"subkeys,omitempty"` + CanSign *bool `json:"can_sign,omitempty"` + CanEncryptComms *bool `json:"can_encrypt_comms,omitempty"` + CanEncryptStorage *bool `json:"can_encrypt_storage,omitempty"` + CanCertify *bool `json:"can_certify,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` + ExpiresAt *time.Time `json:"expires_at,omitempty"` +} + +// String stringifies a GPGKey. +func (k GPGKey) String() string { + return Stringify(k) +} + +// GPGEmail represents an email address associated to a GPG key. +type GPGEmail struct { + Email *string `json:"email,omitempty"` + Verified *bool `json:"verified,omitempty"` +} + +// ListGPGKeys lists the current user's GPG keys. It requires authentication +// via Basic Auth or via OAuth with at least read:gpg_key scope. +// +// GitHub API docs: https://developer.github.com/v3/users/gpg_keys/#list-your-gpg-keys +func (s *UsersService) ListGPGKeys() ([]*GPGKey, *Response, error) { + req, err := s.client.NewRequest("GET", "user/gpg_keys", nil) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeGitSigningPreview) + + var keys []*GPGKey + resp, err := s.client.Do(req, &keys) + if err != nil { + return nil, resp, err + } + + return keys, resp, err +} + +// GetGPGKey gets extended details for a single GPG key. It requires authentication +// via Basic Auth or via OAuth with at least read:gpg_key scope. +// +// GitHub API docs: https://developer.github.com/v3/users/gpg_keys/#get-a-single-gpg-key +func (s *UsersService) GetGPGKey(id int) (*GPGKey, *Response, error) { + u := fmt.Sprintf("user/gpg_keys/%v", id) + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeGitSigningPreview) + + key := &GPGKey{} + resp, err := s.client.Do(req, key) + if err != nil { + return nil, resp, err + } + + return key, resp, err +} + +// CreateGPGKey creates a GPG key. It requires authenticatation via Basic Auth +// or OAuth with at least write:gpg_key scope. +// +// GitHub API docs: https://developer.github.com/v3/users/gpg_keys/#create-a-gpg-key +func (s *UsersService) CreateGPGKey(armoredPublicKey string) (*GPGKey, *Response, error) { + gpgKey := &struct { + ArmoredPublicKey string `json:"armored_public_key"` + }{ArmoredPublicKey: armoredPublicKey} + req, err := s.client.NewRequest("POST", "user/gpg_keys", gpgKey) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeGitSigningPreview) + + key := &GPGKey{} + resp, err := s.client.Do(req, key) + if err != nil { + return nil, resp, err + } + + return key, resp, err +} + +// DeleteGPGKey deletes a GPG key. It requires authentication via Basic Auth or +// via OAuth with at least admin:gpg_key scope. +// +// GitHub API docs: https://developer.github.com/v3/users/gpg_keys/#delete-a-gpg-key +func (s *UsersService) DeleteGPGKey(id int) (*Response, error) { + u := fmt.Sprintf("user/gpg_keys/%v", id) + req, err := s.client.NewRequest("DELETE", u, nil) + if err != nil { + return nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeGitSigningPreview) + + return s.client.Do(req, nil) +} diff --git a/vendor/github.com/google/go-github/github/users_gpg_keys_test.go b/vendor/github.com/google/go-github/github/users_gpg_keys_test.go new file mode 100644 index 00000000..05ef23f1 --- /dev/null +++ b/vendor/github.com/google/go-github/github/users_gpg_keys_test.go @@ -0,0 +1,110 @@ +// Copyright 2016 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "encoding/json" + "fmt" + "net/http" + "reflect" + "testing" +) + +func TestUsersService_ListGPGKeys(t *testing.T) { + setup() + defer teardown() + + mux.HandleFunc("/user/gpg_keys", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testHeader(t, r, "Accept", mediaTypeGitSigningPreview) + fmt.Fprint(w, `[{"id":1,"primary_key_id":2}]`) + }) + + keys, _, err := client.Users.ListGPGKeys() + if err != nil { + t.Errorf("Users.ListGPGKeys returned error: %v", err) + } + + want := []*GPGKey{{ID: Int(1), PrimaryKeyID: Int(2)}} + if !reflect.DeepEqual(keys, want) { + t.Errorf("Users.ListGPGKeys = %+v, want %+v", keys, want) + } +} + +func TestUsersService_GetGPGKey(t *testing.T) { + setup() + defer teardown() + + mux.HandleFunc("/user/gpg_keys/1", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testHeader(t, r, "Accept", mediaTypeGitSigningPreview) + fmt.Fprint(w, `{"id":1}`) + }) + + key, _, err := client.Users.GetGPGKey(1) + if err != nil { + t.Errorf("Users.GetGPGKey returned error: %v", err) + } + + want := &GPGKey{ID: Int(1)} + if !reflect.DeepEqual(key, want) { + t.Errorf("Users.GetGPGKey = %+v, want %+v", key, want) + } +} + +func TestUsersService_CreateGPGKey(t *testing.T) { + setup() + defer teardown() + + input := ` +-----BEGIN PGP PUBLIC KEY BLOCK----- +Comment: GPGTools - https://gpgtools.org + +mQINBFcEd9kBEACo54TDbGhKlXKWMvJgecEUKPPcv7XdnpKdGb3LRw5MvFwT0V0f +... +=tqfb +-----END PGP PUBLIC KEY BLOCK-----` + + mux.HandleFunc("/user/gpg_keys", func(w http.ResponseWriter, r *http.Request) { + var gpgKey struct { + ArmoredPublicKey *string `json:"armored_public_key,omitempty"` + } + json.NewDecoder(r.Body).Decode(&gpgKey) + + testMethod(t, r, "POST") + testHeader(t, r, "Accept", mediaTypeGitSigningPreview) + if gpgKey.ArmoredPublicKey == nil || *gpgKey.ArmoredPublicKey != input { + t.Errorf("gpgKey = %+v, want %q", gpgKey, input) + } + + fmt.Fprint(w, `{"id":1}`) + }) + + gpgKey, _, err := client.Users.CreateGPGKey(input) + if err != nil { + t.Errorf("Users.GetGPGKey returned error: %v", err) + } + + want := &GPGKey{ID: Int(1)} + if !reflect.DeepEqual(gpgKey, want) { + t.Errorf("Users.GetGPGKey = %+v, want %+v", gpgKey, want) + } +} + +func TestUsersService_DeleteGPGKey(t *testing.T) { + setup() + defer teardown() + + mux.HandleFunc("/user/gpg_keys/1", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "DELETE") + testHeader(t, r, "Accept", mediaTypeGitSigningPreview) + }) + + _, err := client.Users.DeleteGPGKey(1) + if err != nil { + t.Errorf("Users.DeleteGPGKey returned error: %v", err) + } +} diff --git a/vendor/github.com/google/go-github/github/users_keys.go b/vendor/github.com/google/go-github/github/users_keys.go index dcbd7737..6a663f52 100644 --- a/vendor/github.com/google/go-github/github/users_keys.go +++ b/vendor/github.com/google/go-github/github/users_keys.go @@ -23,7 +23,7 @@ func (k Key) String() string { // string will fetch keys for the authenticated user. // // GitHub API docs: http://developer.github.com/v3/users/keys/#list-public-keys-for-a-user -func (s *UsersService) ListKeys(user string, opt *ListOptions) ([]Key, *Response, error) { +func (s *UsersService) ListKeys(user string, opt *ListOptions) ([]*Key, *Response, error) { var u string if user != "" { u = fmt.Sprintf("users/%v/keys", user) @@ -40,7 +40,7 @@ func (s *UsersService) ListKeys(user string, opt *ListOptions) ([]Key, *Response return nil, nil, err } - keys := new([]Key) + keys := new([]*Key) resp, err := s.client.Do(req, keys) if err != nil { return nil, resp, err diff --git a/vendor/github.com/google/go-github/github/users_keys_test.go b/vendor/github.com/google/go-github/github/users_keys_test.go index e47afd71..25d4f0ca 100644 --- a/vendor/github.com/google/go-github/github/users_keys_test.go +++ b/vendor/github.com/google/go-github/github/users_keys_test.go @@ -29,7 +29,7 @@ func TestUsersService_ListKeys_authenticatedUser(t *testing.T) { t.Errorf("Users.ListKeys returned error: %v", err) } - want := []Key{{ID: Int(1)}} + want := []*Key{{ID: Int(1)}} if !reflect.DeepEqual(keys, want) { t.Errorf("Users.ListKeys returned %+v, want %+v", keys, want) } @@ -49,7 +49,7 @@ func TestUsersService_ListKeys_specifiedUser(t *testing.T) { t.Errorf("Users.ListKeys returned error: %v", err) } - want := []Key{{ID: Int(1)}} + want := []*Key{{ID: Int(1)}} if !reflect.DeepEqual(keys, want) { t.Errorf("Users.ListKeys returned %+v, want %+v", keys, want) } diff --git a/vendor/github.com/google/go-github/github/users_test.go b/vendor/github.com/google/go-github/github/users_test.go index 0afc8440..db72afa8 100644 --- a/vendor/github.com/google/go-github/github/users_test.go +++ b/vendor/github.com/google/go-github/github/users_test.go @@ -155,18 +155,69 @@ func TestUsersService_ListAll(t *testing.T) { mux.HandleFunc("/users", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - testFormValues(t, r, values{"since": "1"}) + testFormValues(t, r, values{"since": "1", "page": "2"}) fmt.Fprint(w, `[{"id":2}]`) }) - opt := &UserListOptions{1} + opt := &UserListOptions{1, ListOptions{Page: 2}} users, _, err := client.Users.ListAll(opt) if err != nil { t.Errorf("Users.Get returned error: %v", err) } - want := []User{{ID: Int(2)}} + want := []*User{{ID: Int(2)}} if !reflect.DeepEqual(users, want) { t.Errorf("Users.ListAll returned %+v, want %+v", users, want) } } + +func TestUsersService_ListInvitations(t *testing.T) { + setup() + defer teardown() + + mux.HandleFunc("/user/repository_invitations", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testHeader(t, r, "Accept", mediaTypeRepositoryInvitationsPreview) + fmt.Fprintf(w, `[{"id":1}, {"id":2}]`) + }) + + got, _, err := client.Users.ListInvitations() + if err != nil { + t.Errorf("Users.ListInvitations returned error: %v", err) + } + + want := []*RepositoryInvitation{{ID: Int(1)}, {ID: Int(2)}} + if !reflect.DeepEqual(got, want) { + t.Errorf("Users.ListInvitations = %+v, want %+v", got, want) + } +} + +func TestUsersService_AcceptInvitation(t *testing.T) { + setup() + defer teardown() + + mux.HandleFunc("/user/repository_invitations/1", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "PATCH") + testHeader(t, r, "Accept", mediaTypeRepositoryInvitationsPreview) + w.WriteHeader(http.StatusNoContent) + }) + + if _, err := client.Users.AcceptInvitation(1); err != nil { + t.Errorf("Users.AcceptInvitation returned error: %v", err) + } +} + +func TestUsersService_DeclineInvitation(t *testing.T) { + setup() + defer teardown() + + mux.HandleFunc("/user/repository_invitations/1", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "DELETE") + testHeader(t, r, "Accept", mediaTypeRepositoryInvitationsPreview) + w.WriteHeader(http.StatusNoContent) + }) + + if _, err := client.Users.DeclineInvitation(1); err != nil { + t.Errorf("Users.DeclineInvitation returned error: %v", err) + } +} diff --git a/vendor/github.com/google/go-github/tests/integration/activity_test.go b/vendor/github.com/google/go-github/tests/integration/activity_test.go index 1a1a711b..a278584b 100644 --- a/vendor/github.com/google/go-github/tests/integration/activity_test.go +++ b/vendor/github.com/google/go-github/tests/integration/activity_test.go @@ -13,14 +13,19 @@ import ( "github.com/google/go-github/github" ) +const ( + owner = "google" + repo = "go-github" +) + func TestActivity_Starring(t *testing.T) { - stargazers, _, err := client.Activity.ListStargazers("google", "go-github", nil) + stargazers, _, err := client.Activity.ListStargazers(owner, repo, nil) if err != nil { t.Fatalf("Activity.ListStargazers returned error: %v", err) } if len(stargazers) == 0 { - t.Errorf("Activity.ListStargazers('google', 'go-github') returned no stargazers") + t.Errorf("Activity.ListStargazers(%q, %q) returned no stargazers", owner, repo) } // the rest of the tests requires auth @@ -28,54 +33,89 @@ func TestActivity_Starring(t *testing.T) { return } - // first, check if already starred google/go-github - star, _, err := client.Activity.IsStarred("google", "go-github") + // first, check if already starred the target repository + star, _, err := client.Activity.IsStarred(owner, repo) if err != nil { t.Fatalf("Activity.IsStarred returned error: %v", err) } if star { - t.Fatalf("Already starring google/go-github. Please manually unstar it first.") + t.Fatalf("Already starring %v/%v. Please manually unstar it first.", owner, repo) } - // star google/go-github - _, err = client.Activity.Star("google", "go-github") + // star the target repository + _, err = client.Activity.Star(owner, repo) if err != nil { t.Fatalf("Activity.Star returned error: %v", err) } // check again and verify starred - star, _, err = client.Activity.IsStarred("google", "go-github") + star, _, err = client.Activity.IsStarred(owner, repo) if err != nil { t.Fatalf("Activity.IsStarred returned error: %v", err) } if !star { - t.Fatalf("Not starred google/go-github after starring it.") + t.Fatalf("Not starred %v/%v after starring it.", owner, repo) } // unstar - _, err = client.Activity.Unstar("google", "go-github") + _, err = client.Activity.Unstar(owner, repo) if err != nil { t.Fatalf("Activity.Unstar returned error: %v", err) } // check again and verify not watching - star, _, err = client.Activity.IsStarred("google", "go-github") + star, _, err = client.Activity.IsStarred(owner, repo) if err != nil { t.Fatalf("Activity.IsStarred returned error: %v", err) } if star { - t.Fatalf("Still starred google/go-github after unstarring it.") + t.Fatalf("Still starred %v/%v after unstarring it.", owner, repo) + } +} + +func deleteSubscription(t *testing.T) { + // delete subscription + _, err := client.Activity.DeleteRepositorySubscription(owner, repo) + if err != nil { + t.Fatalf("Activity.DeleteRepositorySubscription returned error: %v", err) + } + + // check again and verify not watching + sub, _, err := client.Activity.GetRepositorySubscription(owner, repo) + if err != nil { + t.Fatalf("Activity.GetRepositorySubscription returned error: %v", err) + } + if sub != nil { + t.Fatalf("Still watching %v/%v after deleting subscription.", owner, repo) + } +} + +func createSubscription(t *testing.T) { + // watch the target repository + sub := &github.Subscription{Subscribed: github.Bool(true)} + _, _, err := client.Activity.SetRepositorySubscription(owner, repo, sub) + if err != nil { + t.Fatalf("Activity.SetRepositorySubscription returned error: %v", err) + } + + // check again and verify watching + sub, _, err = client.Activity.GetRepositorySubscription(owner, repo) + if err != nil { + t.Fatalf("Activity.GetRepositorySubscription returned error: %v", err) + } + if sub == nil || !*sub.Subscribed { + t.Fatalf("Not watching %v/%v after setting subscription.", owner, repo) } } func TestActivity_Watching(t *testing.T) { - watchers, _, err := client.Activity.ListWatchers("google", "go-github", nil) + watchers, _, err := client.Activity.ListWatchers(owner, repo, nil) if err != nil { t.Fatalf("Activity.ListWatchers returned error: %v", err) } if len(watchers) == 0 { - t.Errorf("Activity.ListWatchers('google', 'go-github') returned no watchers") + t.Errorf("Activity.ListWatchers(%q, %q) returned no watchers", owner, repo) } // the rest of the tests requires auth @@ -83,43 +123,18 @@ func TestActivity_Watching(t *testing.T) { return } - // first, check if already watching google/go-github - sub, _, err := client.Activity.GetRepositorySubscription("google", "go-github") + // first, check if already watching the target repository + sub, _, err := client.Activity.GetRepositorySubscription(owner, repo) if err != nil { t.Fatalf("Activity.GetRepositorySubscription returned error: %v", err) } - if sub != nil { - t.Fatalf("Already watching google/go-github. Please manually stop watching it first.") - } - // watch google/go-github - sub = &github.Subscription{Subscribed: github.Bool(true)} - _, _, err = client.Activity.SetRepositorySubscription("google", "go-github", sub) - if err != nil { - t.Fatalf("Activity.SetRepositorySubscription returned error: %v", err) - } - - // check again and verify watching - sub, _, err = client.Activity.GetRepositorySubscription("google", "go-github") - if err != nil { - t.Fatalf("Activity.GetRepositorySubscription returned error: %v", err) - } - if sub == nil || !*sub.Subscribed { - t.Fatalf("Not watching google/go-github after setting subscription.") - } - - // delete subscription - _, err = client.Activity.DeleteRepositorySubscription("google", "go-github") - if err != nil { - t.Fatalf("Activity.DeleteRepositorySubscription returned error: %v", err) - } - - // check again and verify not watching - sub, _, err = client.Activity.GetRepositorySubscription("google", "go-github") - if err != nil { - t.Fatalf("Activity.GetRepositorySubscription returned error: %v", err) - } - if sub != nil { - t.Fatalf("Still watching google/go-github after deleting subscription.") + switch { + case sub != nil: // If already subscribing, delete then recreate subscription. + deleteSubscription(t) + createSubscription(t) + case sub == nil: // Otherwise, create subscription and then delete it. + createSubscription(t) + deleteSubscription(t) } } diff --git a/vendor/github.com/google/go-github/tests/integration/repos_test.go b/vendor/github.com/google/go-github/tests/integration/repos_test.go index 6d97ca08..628cccf7 100644 --- a/vendor/github.com/google/go-github/tests/integration/repos_test.go +++ b/vendor/github.com/google/go-github/tests/integration/repos_test.go @@ -145,3 +145,30 @@ func TestRepositories_EditBranches(t *testing.T) { t.Fatalf("Repositories.Delete() returned error: %v", err) } } + +func TestRepositories_List(t *testing.T) { + if !checkAuth("TestRepositories_List") { + return + } + + _, _, err := client.Repositories.List("", nil) + if err != nil { + t.Fatalf("Repositories.List('') returned error: %v", err) + } + + _, _, err = client.Repositories.List("google", nil) + if err != nil { + t.Fatalf("Repositories.List('google') returned error: %v", err) + } + + opt := github.RepositoryListOptions{Sort: "created"} + repos, _, err := client.Repositories.List("google", &opt) + if err != nil { + t.Fatalf("Repositories.List('google') with Sort opt returned error: %v", err) + } + for i, repo := range repos { + if i > 0 && (*repos[i-1].CreatedAt).Time.Before((*repo.CreatedAt).Time) { + t.Fatalf("Repositories.List('google') with default descending Sort returned incorrect order") + } + } +} diff --git a/vendor/github.com/google/go-github/tests/integration/users_test.go b/vendor/github.com/google/go-github/tests/integration/users_test.go index 1ec1843b..9d6764ff 100644 --- a/vendor/github.com/google/go-github/tests/integration/users_test.go +++ b/vendor/github.com/google/go-github/tests/integration/users_test.go @@ -170,6 +170,7 @@ func TestUsers_Keys(t *testing.T) { return } + // TODO: make this integration test work for any authenticated user. keys, _, err = client.Users.ListKeys("", nil) if err != nil { t.Fatalf("Users.ListKeys('') returned error: %v", err)