Browse Source

Fetch user if no --owner is given (#17)

tags/v0.0.10
Jonas Franz Gitea 1 year ago
parent
commit
82ea2d47b7
5 changed files with 21 additions and 18 deletions
  1. +3
    -14
      Gopkg.lock
  2. +8
    -1
      cmd/migrate-all.go
  3. +8
    -1
      cmd/migrate.go
  4. +1
    -1
      migrations/migratory.go
  5. +1
    -1
      migrations/repo.go

+ 3
- 14
Gopkg.lock View File

@@ -5,7 +5,7 @@
branch = "master"
name = "code.gitea.io/sdk"
packages = ["gitea"]
revision = "39c609e903992e25deca0e7aa2c5304fd680530f"
revision = "79a281c4e34ae44cf96a23f0283729a074a6c2a0"

[[projects]]
name = "github.com/davecgh/go-spew"
@@ -37,20 +37,9 @@
revision = "792786c7400a136282c1664665ae0a8db921c6c2"
version = "v1.0.0"

[[projects]]
name = "github.com/stretchr/objx"
packages = ["."]
revision = "477a77ecc69700c7cdeb1fa9e129548e1c1c393c"
version = "v0.1.1"

[[projects]]
name = "github.com/stretchr/testify"
packages = [
".",
"assert",
"http",
"mock"
]
packages = ["assert"]
revision = "f35b8ab0b5a2cef36673838d662e249dd9c94686"
version = "v1.2.2"

@@ -95,6 +84,6 @@
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "884bf618611f0aaad19defa64a14fa70fd2b522afe8cf99dedbfada2a9d8b88d"
inputs-digest = "a63a8945bd36ecc14dfbb7f9894543855f9e9e2e493dfdb77c06b4a12aada8a4"
solver-name = "gps-cdcl"
solver-version = 1

+ 8
- 1
cmd/migrate-all.go View File

@@ -30,7 +30,14 @@ func runMigrateAll(ctx *cli.Context) error {
m := &migrations.Migratory{
Client: gitea.NewClient(ctx.String("url"), ctx.String("token")),
Private: ctx.Bool("private"),
NewOwnerID: ctx.Int("owner"),
NewOwnerID: ctx.Int64("owner"),
}
if m.NewOwnerID == 0 {
usr, err := m.Client.GetMyUserInfo()
if err != nil {
return fmt.Errorf("cannot fetch user info about current user: %v", err)
}
m.NewOwnerID = usr.ID
}
c := context.Background()



+ 8
- 1
cmd/migrate.go View File

@@ -31,7 +31,14 @@ func runMigrate(ctx *cli.Context) error {
m := &migrations.Migratory{
Client: gitea.NewClient(ctx.String("url"), ctx.String("token")),
Private: ctx.Bool("private"),
NewOwnerID: ctx.Int("owner"),
NewOwnerID: ctx.Int64("owner"),
}
if m.NewOwnerID == 0 {
usr, err := m.Client.GetMyUserInfo()
if err != nil {
return fmt.Errorf("cannot fetch user info about current user: %v", err)
}
m.NewOwnerID = usr.ID
}
c := context.Background()
var gc *github.Client


+ 1
- 1
migrations/migratory.go View File

@@ -9,7 +9,7 @@ type Migratory struct {
AuthPassword string

Private bool
NewOwnerID int
NewOwnerID int64

repository *gitea.Repository
// key: github milestone id | value: gitea milestone id


+ 1
- 1
migrations/repo.go View File

@@ -14,7 +14,7 @@ func (m *Migratory) Repository(gr *github.Repository) (*gitea.Repository, error)
AuthUsername: m.AuthUsername,
CloneAddr: gr.GetCloneURL(),
RepoName: gr.GetName(),
UID: m.NewOwnerID,
UID: int(m.NewOwnerID),
Private: m.Private,
})
return m.repository, err


Loading…
Cancel
Save