Skip to content

Commit

Permalink
na
Browse files Browse the repository at this point in the history
  • Loading branch information
fastgh committed Nov 20, 2020
1 parent 3350a9a commit c7a3db8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions cmdline.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type CommandLineT struct {
GitURLText string
ArgIndexOfGitURLText int
PerhapsNeedInstrument bool
IsPrivate bool
UseProxy bool
Args []string
}

Expand All @@ -88,8 +88,8 @@ func filterExtendedArguments(r CommandLine) {
for i := 1; i < len(os.Args); i++ {
arg := os.Args[i]

if arg == "--private" {
r.IsPrivate = true
if arg == "--use-proxy" {
r.UseProxy = true
continue
}
if arg == "--debug" {
Expand Down Expand Up @@ -119,7 +119,7 @@ func resolveSubCommand(r CommandLine) {
r.SubCommand = arg0
r.PerhapsNeedInstrument = true
if arg0 == "push" {
r.IsPrivate = true
r.UseProxy = true
}
}
}
Expand All @@ -134,7 +134,7 @@ func ParseCommandLine() CommandLine {
GitURLText: "",
ArgIndexOfGitURLText: -1,
PerhapsNeedInstrument: false,
IsPrivate: false,
UseProxy: false,
Args: []string{},
}

Expand Down Expand Up @@ -410,7 +410,7 @@ func parsePushCommand(r CommandLine) {

r.PerhapsNeedInstrument = true

r.IsPrivate = true
r.UseProxy = true
}

var cloneOptions = []GitOptionT{
Expand Down
2 changes: 1 addition & 1 deletion git_instrument.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var instrumentContext = &InstrumentContextT{}
func GithubInstrument(cmdline CommandLine, config Config) {
ictx := instrumentContext

if cmdline.IsPrivate {
if cmdline.UseProxy {
ictx.UseMirror = false
} else {
ictx.UseMirror = true
Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ func main() {
panic(fmt.Errorf("fgit不支持%s,仅支持https", gitURL.Scheme))
}

if cmdline.IsPrivate == false && len(gitURL.User.Username()) > 0 {
cmdline.IsPrivate = true
if cmdline.UseProxy == false && len(gitURL.User.Username()) > 0 {
cmdline.UseProxy = true

if Debug {
log.Println("[fgit] 发现URL中嵌入有用户名,因此设置为私有库模式")
log.Println("[fgit] 发现URL中嵌入有用户名,因此改为使用代理服务器")
}
}

Expand Down

0 comments on commit c7a3db8

Please sign in to comment.