Skip to content

Commit

Permalink
Factor UserAgent to fs and move Version to fs
Browse files Browse the repository at this point in the history
  • Loading branch information
ncw committed Jul 13, 2014
1 parent e40b09f commit c1a245d
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 15 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ serve:
tag:
@echo "Old tag is $(LAST_TAG)"
@echo "New tag is $(NEW_TAG)"
echo -e "package main\n const Version = \"$(NEW_TAG)\"\n" | gofmt > version.go
cp -av version.go rclonetest/version.go
echo -e "package fs\n const Version = \"$(NEW_TAG)\"\n" | gofmt > fs/version.go
perl -lpe 's/VERSION/${NEW_TAG}/g; s/DATE/'`date -I`'/g;' docs/content/downloads.md.in > docs/content/downloads.md
git tag $(NEW_TAG)
@echo "Add this to changelog in README.md"
Expand Down
2 changes: 1 addition & 1 deletion drive/drive.go
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ func (o *FsObjectDrive) Storable() bool {
// Open an object for read
func (o *FsObjectDrive) Open() (in io.ReadCloser, err error) {
req, _ := http.NewRequest("GET", o.url, nil)
req.Header.Set("User-Agent", "rclone/1.0")
req.Header.Set("User-Agent", fs.UserAgent)
res, err := o.drive.client.Do(req)
if err != nil {
return nil, err
Expand Down
6 changes: 6 additions & 0 deletions fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import (
"time"
)

// Constants
const (
// User agent for Fs which can set it
UserAgent = "rclone/" + Version
)

// Globals
var (
// Filesystem registry
Expand Down
2 changes: 1 addition & 1 deletion rclonetest/version.go → fs/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package main
package fs

const Version = "v1.01"
2 changes: 1 addition & 1 deletion notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Making a release
* cd ..
* make tag
* edit README.md
* git commit version.go rclonetest/version.go README.md docs/content/downloads.md
* git commit fs/version.go README.md docs/content/downloads.md
* make retag
* . ~/bin/go-cross
* make cross
Expand Down
4 changes: 2 additions & 2 deletions rclone.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ Syntax: [options] subcommand <parameters> <parameters...>
Subcommands:
`, Version)
`, fs.Version)
for i := range Commands {
cmd := &Commands[i]
fmt.Fprintf(os.Stderr, " %s %s\n", cmd.Name, cmd.ArgsHelp)
Expand Down Expand Up @@ -329,7 +329,7 @@ func StartStats() {
func main() {
ParseFlags()
if *version {
fmt.Printf("rclone %s\n", Version)
fmt.Printf("rclone %s\n", fs.Version)
os.Exit(0)
}
command, args := ParseCommand()
Expand Down
4 changes: 2 additions & 2 deletions rclonetest/rclonetest.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ directory under it and perform tests on it, deleting it at the end.
Options:
`, Version)
`, fs.Version)
pflag.PrintDefaults()
}

Expand All @@ -316,7 +316,7 @@ func main() {
pflag.Usage = syntaxError
pflag.Parse()
if *version {
fmt.Printf("rclonetest %s\n", Version)
fmt.Printf("rclonetest %s\n", fs.Version)
os.Exit(0)
}
fs.LoadConfig()
Expand Down
7 changes: 4 additions & 3 deletions swift/swift.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ func swiftConnection(name string) (*swift.Connection, error) {
return nil, errors.New("auth not found")
}
c := &swift.Connection{
UserName: userName,
ApiKey: apiKey,
AuthUrl: authUrl,
UserName: userName,
ApiKey: apiKey,
AuthUrl: authUrl,
UserAgent: fs.UserAgent,
}
err := c.Authenticate()
if err != nil {
Expand Down
3 changes: 0 additions & 3 deletions version.go

This file was deleted.

0 comments on commit c1a245d

Please sign in to comment.