Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
U
Unity
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Shane Veasy
Unity
Commits
bf8a2ae6
Commit
bf8a2ae6
authored
7 years ago
by
Stanley Goldman
Browse files
Options
Downloads
Patches
Plain Diff
Adding warning message if branch already exists
parent
089d0107
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs
+38
-14
38 additions, 14 deletions
...tyExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs
with
38 additions
and
14 deletions
src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs
+
38
−
14
View file @
bf8a2ae6
...
...
@@ -16,9 +16,12 @@ namespace GitHub.Unity
private
const
string
ConfirmSwitchOK
=
"Switch"
;
private
const
string
ConfirmSwitchCancel
=
"Cancel"
;
private
const
string
ConfirmCheckoutBranchTitle
=
"Confirm branch checkout"
;
private
const
string
ConfirmCheckoutBranchMessage
=
"Checkout branch {0}?"
;
private
const
string
ConfirmCheckoutBranchMessage
=
"Checkout branch {0}
from {1}
?"
;
private
const
string
ConfirmCheckoutBranchOK
=
"Checkout"
;
private
const
string
ConfirmCheckoutBranchCancel
=
"Cancel"
;
private
const
string
WarningCheckoutBranchExistsTitle
=
"Branch already exists"
;
private
const
string
WarningCheckoutBranchExistsMessage
=
"Branch {0} already exists"
;
private
const
string
WarningCheckoutBranchExistsOK
=
"Ok"
;
private
const
string
NewBranchCancelButton
=
"x"
;
private
const
string
NewBranchConfirmButton
=
"Create"
;
private
const
string
FavoritesSetting
=
"Favorites"
;
...
...
@@ -668,32 +671,53 @@ namespace GitHub.Unity
.
FinallyInUI
((
success
,
e
)
=>
{
if
(
success
)
{
Refresh
();
}
else
{
EditorUtility
.
DisplayDialog
(
Localization
.
SwitchBranchTitle
,
String
.
Format
(
Localization
.
SwitchBranchFailedDescription
,
node
.
Name
),
Localization
.
Ok
);
Localization
.
Ok
);
}
}).
Start
();
}
}
else
if
(
node
.
Type
==
NodeType
.
RemoteBranch
)
{
if
(
EditorUtility
.
DisplayDialog
(
ConfirmCheckoutBranchTitle
,
String
.
Format
(
ConfirmCheckoutBranchMessage
,
node
.
Name
),
ConfirmCheckoutBranchOK
,
ConfirmCheckoutBranchCancel
))
var
indexOfFirstSlash
=
selectedNode
.
Name
.
IndexOf
(
'/'
);
var
originName
=
selectedNode
.
Name
.
Substring
(
0
,
indexOfFirstSlash
);
var
branchName
=
selectedNode
.
Name
.
Substring
(
indexOfFirstSlash
+
1
);
if
(
Repository
.
LocalBranches
.
Any
(
localBranch
=>
localBranch
.
Name
==
branchName
))
{
GitClient
.
CreateBranch
(
selectedNode
.
Name
.
Substring
(
selectedNode
.
Name
.
IndexOf
(
'/'
)
+
1
),
selectedNode
.
Name
)
.
FinallyInUI
((
success
,
e
)
=>
{
if
(
success
)
Refresh
();
else
EditorUtility
.
DisplayDialog
(
WarningCheckoutBranchExistsTitle
,
String
.
Format
(
WarningCheckoutBranchExistsMessage
,
branchName
),
WarningCheckoutBranchExistsOK
);
}
else
{
var
confirmCheckout
=
EditorUtility
.
DisplayDialog
(
ConfirmCheckoutBranchTitle
,
String
.
Format
(
ConfirmCheckoutBranchMessage
,
node
.
Name
,
originName
),
ConfirmCheckoutBranchOK
,
ConfirmCheckoutBranchCancel
);
if
(
confirmCheckout
)
{
GitClient
.
CreateBranch
(
branchName
,
selectedNode
.
Name
)
.
FinallyInUI
((
success
,
e
)
=>
{
EditorUtility
.
DisplayDialog
(
Localization
.
SwitchBranchTitle
,
String
.
Format
(
Localization
.
SwitchBranchFailedDescription
,
node
.
Name
),
Localization
.
Ok
);
}
}).
Start
();
if
(
success
)
{
Refresh
();
}
else
{
EditorUtility
.
DisplayDialog
(
Localization
.
SwitchBranchTitle
,
String
.
Format
(
Localization
.
SwitchBranchFailedDescription
,
node
.
Name
),
Localization
.
Ok
);
}
}).
Start
();
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment