-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try to resolve the issue with JetBrains computer names in TFS workspaces #212
Open
AlexRukhlin
wants to merge
3
commits into
master
Choose a base branch
from
users/arukhlin/comp_name
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,8 @@ public abstract class LocalHost { | |
* Where the cached computer name string goes. | ||
*/ | ||
private static String computerName; | ||
// JetBrains TFS plugin compatible name | ||
private static String computerNameJB; | ||
|
||
/** | ||
* <p> | ||
|
@@ -108,9 +110,53 @@ public synchronized static String getShortName() { | |
name.substring(0, (name.length() > MAX_COMPUTER_NAME_SIZE) ? MAX_COMPUTER_NAME_SIZE : name.length()); | ||
} | ||
|
||
log.info("Short name resolved to: " + computerNameJB); //$NON-NLS-1$ | ||
return computerName; | ||
} | ||
|
||
/** | ||
* <p> | ||
* Gets the short name of the current computer compatible with JetBrains TFS | ||
* plugin. | ||
* <p> | ||
* The only difference with the traditional TEE method | ||
* {@link #getShortName()} is in the order of particular name detection | ||
* sub-method calls. This method prefers {@link #getPureJavaShortName()}. | ||
* </p> | ||
* <p> | ||
* The {@link #SHORT_NAME_OVERRIDE_PROPERTY} may be used to define the | ||
* computer name exactly. | ||
* </p> | ||
* | ||
* <p> | ||
* We un-set the computerName variable, because we might need to recalculate | ||
* it since the system property {@link #SHORT_NAME_OVERRIDE_PROPERTY} might | ||
* change after call {@link #getShortNameJB()} in | ||
* {@link com.microsoft.tfs.client.clc.commands.Command#determineCachedWorkspace()}. | ||
* </p> | ||
* | ||
* @return a short identifier (name of this computer). Never | ||
* <code>null</code> or empty. | ||
*/ | ||
public synchronized static String getShortNameJB() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the same way to figure out the short name like JetBrains |
||
|
||
computerName = null; | ||
|
||
if (computerNameJB == null) { | ||
String name = getPureJavaShortName(); | ||
|
||
if (name != null) { | ||
// Cache the name forever. Truncate if too long. | ||
computerNameJB = name.substring( | ||
0, | ||
(name.length() > MAX_COMPUTER_NAME_SIZE) ? MAX_COMPUTER_NAME_SIZE : name.length()); | ||
log.info("Short name resolved to: " + computerNameJB); //$NON-NLS-1$ | ||
} | ||
} | ||
|
||
return computerNameJB; | ||
} | ||
|
||
/** | ||
* Gets the host name using environment variables. Many major versions of | ||
* Java do not support reading environment variables, and on those platforms | ||
|
@@ -224,9 +270,9 @@ private static String getMadeUpShortName() { | |
*/ | ||
private static String getPureJavaShortName() { | ||
/* | ||
* I have a feeling this may fail for some computers with unusual network | ||
* configurations (lots of interfaces; no DNS; etc.). It may need to be | ||
* scrapped and re-written. | ||
* I have a feeling this may fail for some computers with unusual | ||
* network configurations (lots of interfaces; no DNS; etc.). It may | ||
* need to be scrapped and re-written. | ||
*/ | ||
String name = null; | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be computerName not computerNameJB?