Skip to content

Commit 199ea1a

Browse files
committed
Merge remote-tracking branch 'upstream/master' into development
2 parents 270c095 + 69aa991 commit 199ea1a

8 files changed

Lines changed: 191 additions & 82 deletions

File tree

CHANGELOG.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ The exercism CLI follows [semantic versioning](http://semver.org/).
77
## Next Release
88
* **Your contribution here**
99

10+
## v3.0.11 (2018-11-18)
11+
* [#752](https://github.com/exercism/cli/pull/752) Improve error message on upgrade command - [@farisj]
12+
* [#759](https://github.com/exercism/cli/pull/759) Update shell tab completion for bash and zsh - [@nywilken]
13+
* [#762](https://github.com/exercism/cli/pull/762) Improve usage documentation - [@Smarticles101]
14+
* [#766](https://github.com/exercism/cli/pull/766) Tweak messaging to work for teams edition - [@kytrinyx]
15+
1016
## v3.0.10 (2018-10-03)
1117
* official release of v3.0.10-alpha.1 - [@nywilken]
1218

@@ -402,8 +408,12 @@ All changes by [@msgehard]
402408
* Implement login and logout
403409
* Build on Travis
404410

405-
[@alebaffa]: https://github.com/alebaffa
406411
[@AlexWheeler]: https://github.com/AlexWheeler
412+
[@Dparker1990]: https://github.com/Dparker1990
413+
[@LegalizeAdulthood]: https://github.com/LegalizeAdulthood
414+
[@Tonkpils]: https://github.com/Tonkpils
415+
[@TrevorBramble]: https://github.com/TrevorBramble
416+
[@alebaffa]: https://github.com/alebaffa
407417
[@ambroff]: https://github.com/ambroff
408418
[@andrewsardone]: https://github.com/andrewsardone
409419
[@anxiousmodernman]: https://github.com/anxiousmodernman
@@ -414,27 +424,26 @@ All changes by [@msgehard]
414424
[@cookrn]: https://github.com/cookrn
415425
[@daveyarwood]: https://github.com/daveyarwood
416426
[@devonestes]: https://github.com/devonestes
417-
[@Dparker1990]: https://github.com/Dparker1990
418427
[@djquan]: https://github.com/djquan
419428
[@dmmulroy]: https://github.com/dmmulroy
420429
[@dpritchett]: https://github.com/dpritchett
421430
[@eToThePiIPower]: https://github.com/eToThePiIPower
422431
[@ebautistabar]: https://github.com/ebautistabar
423432
[@elimisteve]: https://github.com/elimisteve
424433
[@ests]: https://github.com/ests
434+
[@farisj]: https://github.com/farisj
425435
[@glebedel]: https://github.com/glebedel
426436
[@harimp]: https://github.com/harimp
427437
[@hjljo]: https://github.com/hjljo
428438
[@isbadawi]: https://github.com/isbadawi
429-
[@jdsutherland]: https://github.com/jdsutherland
430439
[@jbaiter]: https://github.com/jbaiter
440+
[@jdsutherland]: https://github.com/jdsutherland
431441
[@jgsqware]: https://github.com/jgsqware
432442
[@jish]: https://github.com/jish
433443
[@jppunnett]: https://github.com/jppunnett
434-
[@kytrinyx]: https://github.com/kytrinyx
435444
[@katrinleinweber]: https://github.com/katrinleinweber
445+
[@kytrinyx]: https://github.com/kytrinyx
436446
[@lcowell]: https://github.com/lcowell
437-
[@LegalizeAdulthood]: https://github.com/LegalizeAdulthood
438447
[@manusajith]: https://github.com/manusajith
439448
[@morphatic]: https://github.com/morphatic
440449
[@mrageh]: https://github.com/mrageh
@@ -452,7 +461,6 @@ All changes by [@msgehard]
452461
[@sfairchild]: https://github.com/sfairchild
453462
[@simonjefford]: https://github.com/simonjefford
454463
[@srt32]: https://github.com/srt32
455-
[@Tonkpils]: https://github.com/Tonkpils
456-
[@TrevorBramble]: https://github.com/TrevorBramble
457464
[@williandrade]: https://github.com/williandrade
458465
[@zabawaba99]: https://github.com/zabawaba99
466+
[@Smarticles101]: https://github.com/Smarticles101

RELEASE.md

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ $ sudo GCO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 ./make.bash --no-clean
2424
Make sure all the recent changes are reflected in the "next release" section
2525
of the Changelog. Make this a separate commit from bumping the version.
2626

27+
You can view changes using the /compare/ view:
28+
https://github.com/exercism/cli/compare/$PREVIOUS_RELEASE...master
29+
2730
## Bump the version
2831

29-
Edit the `Version` constant in `exercism/main.go`, and edit the Changelog.
32+
Edit the `Version` constant in `cmd/version.go`, and edit the Changelog.
3033

3134
All the changes in the "next release" section should be moved to a new section
3235
that describes the version number, and gives it a date.
@@ -51,25 +54,15 @@ VERSION matches the value of the `Version` constant.
5154

5255
Upload all the binaries from `release/*`.
5356

54-
Paste the release text and describe the new changes (`tail -n +57 RELEASE.md | head -n 16 | pbcopy`):
57+
Paste the release text and describe the new changes.
5558

5659
```
57-
### Exercism Command-Line Interface (CLI)
58-
59-
Exercism takes place in two places: the discussions happen on the website, and you work on exercises locally. The CLI bridges the gap, allowing you to fetch exercises and submit solutions to the site.
60-
61-
This is a stand-alone binary, which means that you don't need to install any particular language or environment in order to use it.
62-
63-
To install, download the archive that matches your operating system and architecture, unpack the archive, and put the binary somewhere on your path.
64-
65-
You will need to configure the CLI with your [Exercism API Key](http://exercism.io/account/key) before submitting.
60+
To install, follow the interactive installation instructions at https://exercism.io/cli-walkthrough
6661
67-
For more detailed instructions, see the [CLI page on Exercism](http://exercism.io/cli).
62+
---
6863
69-
#### Recent changes
64+
[describe changes in this release]
7065
71-
* ABC...
72-
* XYZ...
7366
```
7467

7568
## Update Homebrew

cmd/cmd.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
package cmd
22

3+
import (
4+
"fmt"
5+
6+
"github.com/exercism/cli/config"
7+
"github.com/spf13/viper"
8+
)
9+
310
const msgWelcomePleaseConfigure = `
411
512
Welcome to Exercism!
@@ -33,3 +40,18 @@ const msgMissingMetadata = `
3340
Please see https://exercism.io/cli-v1-to-v2 for instructions on how to fix it.
3441
3542
`
43+
44+
// validateUserConfig validates the presense of required user config values
45+
func validateUserConfig(cfg *viper.Viper) error {
46+
if cfg.GetString("token") == "" {
47+
return fmt.Errorf(
48+
msgWelcomePleaseConfigure,
49+
config.SettingsURL(cfg.GetString("apibaseurl")),
50+
BinaryName,
51+
)
52+
}
53+
if cfg.GetString("workspace") == "" || cfg.GetString("apibaseurl") == "" {
54+
return fmt.Errorf(msgRerunConfigure, BinaryName)
55+
}
56+
return nil
57+
}

cmd/configure_test.go

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@ import (
1818
)
1919

2020
func TestBareConfigure(t *testing.T) {
21-
oldErr := Err
22-
defer func() {
23-
Err = oldErr
24-
}()
25-
26-
var buf bytes.Buffer
27-
Err = &buf
28-
2921
flags := pflag.NewFlagSet("fake", pflag.PanicOnError)
3022
setupConfigureFlags(flags)
3123

@@ -40,7 +32,9 @@ func TestBareConfigure(t *testing.T) {
4032
}
4133

4234
err = runConfigure(cfg, flags)
43-
assert.Regexp(t, "no token configured", err.Error())
35+
if assert.Error(t, err) {
36+
assert.Regexp(t, "no token configured", err.Error())
37+
}
4438
}
4539

4640
func TestConfigureShow(t *testing.T) {
@@ -49,8 +43,7 @@ func TestConfigureShow(t *testing.T) {
4943
Err = oldErr
5044
}()
5145

52-
var buf bytes.Buffer
53-
Err = &buf
46+
Err = &bytes.Buffer{}
5447

5548
flags := pflag.NewFlagSet("fake", pflag.PanicOnError)
5649
setupConfigureFlags(flags)
@@ -82,7 +75,7 @@ func TestConfigureShow(t *testing.T) {
8275
assert.NotRegexp(t, "override.example", Err)
8376

8477
assert.Regexp(t, "configured-token", Err)
85-
assert.NotRegexp(t, "token-overrid", Err)
78+
assert.NotRegexp(t, "token-override", Err)
8679

8780
assert.Regexp(t, "configured-workspace", Err)
8881
assert.NotRegexp(t, "workspace-override", Err)
@@ -150,17 +143,12 @@ func TestConfigureToken(t *testing.T) {
150143
defer ts.Close()
151144

152145
oldOut := Out
153-
oldErr := Err
154146
Out = ioutil.Discard
155147
defer func() {
156148
Out = oldOut
157-
Err = oldErr
158149
}()
159150

160151
for _, tc := range testCases {
161-
var buf bytes.Buffer
162-
Err = &buf
163-
164152
flags := pflag.NewFlagSet("fake", pflag.PanicOnError)
165153
setupConfigureFlags(flags)
166154

@@ -238,17 +226,12 @@ func TestConfigureAPIBaseURL(t *testing.T) {
238226
}
239227

240228
oldOut := Out
241-
oldErr := Err
242229
Out = ioutil.Discard
243230
defer func() {
244231
Out = oldOut
245-
Err = oldErr
246232
}()
247233

248234
for _, tc := range testCases {
249-
var buf bytes.Buffer
250-
Err = &buf
251-
252235
flags := pflag.NewFlagSet("fake", pflag.PanicOnError)
253236
setupConfigureFlags(flags)
254237

@@ -398,8 +381,9 @@ func TestConfigureDefaultWorkspaceWithoutClobbering(t *testing.T) {
398381
assert.NoError(t, err)
399382

400383
err = runConfigure(cfg, flags)
401-
assert.Error(t, err)
402-
assert.Regexp(t, "already something", err.Error())
384+
if assert.Error(t, err) {
385+
assert.Regexp(t, "already something", err.Error())
386+
}
403387
}
404388

405389
func TestConfigureExplicitWorkspaceWithoutClobberingNonDirectory(t *testing.T) {

cmd/download.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,8 @@ Download other people's solutions by providing the UUID.
5050

5151
func runDownload(cfg config.Config, flags *pflag.FlagSet, args []string) error {
5252
usrCfg := cfg.UserViperConfig
53-
if usrCfg.GetString("token") == "" {
54-
return fmt.Errorf(msgWelcomePleaseConfigure, config.SettingsURL(usrCfg.GetString("apibaseurl")), BinaryName)
55-
}
56-
if usrCfg.GetString("workspace") == "" || usrCfg.GetString("apibaseurl") == "" {
57-
return fmt.Errorf(msgRerunConfigure, BinaryName)
53+
if err := validateUserConfig(usrCfg); err != nil {
54+
return err
5855
}
5956

6057
uuid, err := flags.GetString("uuid")

cmd/submit.go

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,8 @@ var submitCmd = &cobra.Command{
5353
func runSubmit(cfg config.Config, flags *pflag.FlagSet, args []string) error {
5454
usrCfg := cfg.UserViperConfig
5555

56-
if usrCfg.GetString("token") == "" {
57-
return fmt.Errorf(msgWelcomePleaseConfigure, config.SettingsURL(usrCfg.GetString("apibaseurl")), BinaryName)
58-
}
59-
60-
if usrCfg.GetString("workspace") == "" {
61-
return fmt.Errorf(msgRerunConfigure, BinaryName)
56+
if err := validateUserConfig(usrCfg); err != nil {
57+
return err
6258
}
6359

6460
for i, arg := range args {
@@ -136,15 +132,28 @@ func runSubmit(cfg config.Config, flags *pflag.FlagSet, args []string) error {
136132
return err
137133
}
138134
if verbose, _ := flags.GetBool("verbose"); verbose {
139-
fmt.Fprintf(os.Stderr, migrationStatus.String())
135+
fmt.Fprintf(Err, migrationStatus.String())
140136
}
141137
metadata, err := workspace.NewExerciseMetadata(exerciseDir)
142138
if err != nil {
143139
return err
144140
}
145141

142+
if exercise.Slug != metadata.Exercise {
143+
// TODO: error msg should suggest running future doctor command
144+
msg := `
145+
146+
The exercise directory does not match exercise slug in metadata:
147+
148+
expected '%[1]s' but got '%[2]s'
149+
150+
Please rename the directory '%[1]s' to '%[2]s' and try again.
151+
152+
`
153+
return fmt.Errorf(msg, exercise.Slug, metadata.Exercise)
154+
}
155+
146156
if !metadata.IsRequester {
147-
// TODO: add test
148157
msg := `
149158
150159
The solution you are submitting is not connected to your account.
@@ -263,7 +272,7 @@ func runSubmit(cfg config.Config, flags *pflag.FlagSet, args []string) error {
263272
%s
264273
`
265274
suffix := "View it at:\n\n "
266-
if metadata.AutoApprove {
275+
if metadata.AutoApprove && metadata.Team == "" {
267276
suffix = "You can complete the exercise and unlock the next core exercise at:\n"
268277
}
269278
fmt.Fprintf(Err, msg, suffix)

0 commit comments

Comments
 (0)