Merge lp:~gz/juju-core/force_version_error into lp:~go-bot/juju-core/trunk

Proposed by Martin Packman
Status: Merged
Approved by: Martin Packman
Approved revision: no longer in the source branch.
Merged at revision: 1861
Proposed branch: lp:~gz/juju-core/force_version_error
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 17 lines (+3/-3)
1 file modified
version/version.go (+3/-3)
To merge this branch: bzr merge lp:~gz/juju-core/force_version_error
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+186409@code.launchpad.net

Commit message

version: report not panic on unreadable file

Change init() to not panic and instead report issues with
reading FORCE-VERSION to stderr.

https://codereview.appspot.com/13613045/

R=themue

Description of the change

version: report not panic on unreadable file

Change init() to not panic and instead report issues with
reading FORCE-VERSION to stderr.

Unfortunately this seems pretty untestable, as we don't have
a framework for tests that actually need to run binaries.

https://codereview.appspot.com/13613045/

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Reviewers: mp+186409_code.launchpad.net,

Message:
Please take a look.

Description:
version: report not panic on unreadable file

Change init() to not panic and instead report issues with
reading FORCE-VERSION to stderr.

Unfortunately this seems pretty untestable, as we don't have
a framework for tests that actually need to run binaries.

https://code.launchpad.net/~gz/juju-core/force_version_error/+merge/186409

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/13613045/

Affected files (+5, -3 lines):
   A [revision details]
   M version/version.go

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-20130918141205-vzr0marfb2wzqj53
+New revision: <email address hidden>

Index: version/version.go
=== modified file 'version/version.go'
--- version/version.go 2013-09-13 04:16:42 +0000
+++ version/version.go 2013-09-18 17:55:24 +0000
@@ -52,10 +52,10 @@
   toolsDir := filepath.Dir(os.Args[0])
   v, err := ioutil.ReadFile(filepath.Join(toolsDir, "FORCE-VERSION"))
   if err != nil {
- if os.IsNotExist(err) {
- return
+ if !os.IsNotExist(err) {
+ fmt.Fprintf(os.Stderr, "WARNING: cannot read forced version: %v\n", err)
    }
- panic(fmt.Errorf("version: cannot read forced version: %v", err))
+ return
   }
   Current.Number = MustParse(strings.TrimSpace(string(v)))
  }

Revision history for this message
Frank Mueller (themue) wrote :

LGTM, maybe with additional logging.

https://codereview.appspot.com/13613045/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'version/version.go'
2--- version/version.go 2013-09-13 04:16:42 +0000
3+++ version/version.go 2013-09-18 18:07:34 +0000
4@@ -52,10 +52,10 @@
5 toolsDir := filepath.Dir(os.Args[0])
6 v, err := ioutil.ReadFile(filepath.Join(toolsDir, "FORCE-VERSION"))
7 if err != nil {
8- if os.IsNotExist(err) {
9- return
10+ if !os.IsNotExist(err) {
11+ fmt.Fprintf(os.Stderr, "WARNING: cannot read forced version: %v\n", err)
12 }
13- panic(fmt.Errorf("version: cannot read forced version: %v", err))
14+ return
15 }
16 Current.Number = MustParse(strings.TrimSpace(string(v)))
17 }

Subscribers

People subscribed via source and target branches

to status/vote changes: