Recursively ignore within a structured repo using .tfignore - tfs

I have a solution with multiple projects. Each project uses a given Nuget that installs resources in some folders thar are shared with custom files. Something like
Solution
ProjA
Resources
Text <from nuget>
Img
Text
ProjB
Resources
Text <from nuget>
Img
Text
I already tried adding .tfignore at the solution level with
Resources/Text
But it doesn't work. The only way I succeeded was to copy the .tfignore into each project folder. Is there any better way?

.tfignore file will ignore the given pattern in all subdirectories . And it will ignore files or folders with the given name. For folders, it will apply recursively.
As a result, a .tfignore with:
Text
This will ignore any folder named Text in your filesystem hierarchy, and it will ignore them recursively.
For those Text folder which is not under Resources/Tables you can create .tfignore files in sub-folders to override the effects of a .tfignore file in a parent folder.
Note:
A filespec is recursive unless prefixed by the \ character.
This .tfignore file will not affect with those files already in source control. You need to remove them from source control first. Also make sure your .tfignore files have checked in source control.

Related

How to make Visual Studio Intellisense recommend "" Include?

In VS2019, when I have the possibility to include a class, Intellisense only suggests includes with angled brackets (<>). But in most cases I want quote includes ("").
Is there a way to customize it/ let Intellisense suggest both?
Actually, VS does not have such option to automatically switch to realize your requirements. I think this behavior depends on how you reference the header file into the project. So you have to change the way which you import these header files.
Note: <> searches the header files under include directories or additional include directories
while "" searches the header files under your project folder first and then search under include directories or additional include directories.
So the solution is that:
Please remove the path of these header files under include directories and additional include directories.
Then, right-click on the Header Files folder of your c++ project-->Add-->Existing Item to add these header files into your project.
Then, you can see that Intellisense will recommend "" rather than <>.
====================================================
This is my test result:
I have a header file called header.h and I configured its path into additional include directories, and when I call its variable, you can see:
If I removed the path from additional include directories and add it into the Header Files folder.

Flume: How to track specified sub folders using spoolDir?

We're having a system uploads log files into a folder which named by date. It looks like:
/logs
/20181030
/20181031
/20181101
/20181102
/...
Suppose that I want to track the log files which produced during November by using spoolDir, How could I do this ?
#this won't work
a1.sources.r1.spoolDir = /logs/201811??
#this seems only works with files. Is it possible to filter folders here?
a1.sources.r1.includePattern = ^.*\.txt$
Acoording to the flume source code, folders that match the ignorePattern are skipped while recursing the folder tree(to register folder trackers). So you can ignore the folders which don't match your criteria. ^(?!201811..).*$ would exclude all the folders that are not folders of November 2018. Other folders will not be tracked.
But this pattern will also apply to file names. So any file with name that does not match ^201811..$ will also be ignored. You can add the ^.*\.txt$ pattern (the one you are using for the include pattern) to the regex to make flume accept your input files.
a1.sources.r1.ignorePattern = ^(?!(201810..)|(.*\\.txt)).*$
would do the trick for you.

Flume "Spooling Directory Source" recursive-look for the the files within subdirectories

I am looking for the Flume "Spooling Directory Source" recursive-look for the the files within subdirectories.
There are some references here https://issues.apache.org/jira/browse/FLUME-1899
however since then multiple versions have come out, is there any way we can have recursive directory lookup within subdirectories for the files in Spooling Source.
I think you can use the patch FLUME-1899-2.patch directly.
set the "recursiveDirectorySearch" as ture in your config file.
NOTE: the regex in ignorePattern of config file will also affect the recursiveDirectory folder name. so you might need to modify the code in org/apache/flume/client/avro/ReliableSpoolingFileEventReader.java if you want to ignore the folder name.

TFS exclude a directory - .tfignore not working and it is a very large directory

I have seen other posts and read them on stackoverflow - How to ignore files/directories in TFS for avoiding them to go to central source repository?
However this does not seem to work.
I have a folder of the root called /FS which in that directory I have the following .tfignore
################################################################################
# This .tfignore file was automatically created by Microsoft(R) Visual Studio.
#
# Local items matching filespecs in this file will not be added to version
# control. This file can be checked in to share exclusions with others.
#
# Wildcard characters are * and ?. Patterns are matched recursively unless the
# pattern is prefixed by the \ character.
#
# You can prepend a path to a pattern to make it more specific. If you do,
# wildcard characters are not permitted in the path portion.
#
# The # character at the beginning of a line indicates a comment.
#
# The ! prefix negates a pattern. This can be used to re-include an item after
# it was excluded by a .tfignore file higher in the tree, or by the Team
# Project Collection's global exclusions list.
#
# The / character is interpreted as a \ character on Windows platforms.
#
# Examples:
#
# # Excludes all files ending in .txt in Alpha\Beta and all its subfolders.
# Alpha\Beta\*.txt
#
# # Excludes all files ending in .cpp in this folder only.
# \*.cpp
#
# # Excludes all files ending in .cpp in this folder and all subfolders.
# *.cpp
#
# # If "Contoso" is a folder, then Contoso and all its children are excluded.
# # If it is a file, then only the "Contoso" in this folder is excluded.
# \Contoso
#
# # If Help.exe is excluded by a higher .tfignore file or by the Team Project
# # Collection global exclusions list, then this pattern re-includes it in
# # this folder only.
# !\Help.exe
#
################################################################################
\BRAND
\CO
\COVER
\COVERBANNER
\DEPT
\DEPT-CATS
\LIB
\PRODUCTS
However, TFS keeps trying to add these directories. I even have at the root directory another .tfignore
/FS
I simply need /FS out of TFS. This is 15GB workth of images that does not belong in SOURCE control, we have multiple areas where these images are backed up and this is very resource intense creating branches.
Do I need to delete the /FS from TFS with CMD PROMPT? Any help would be great. I am simply frustrated and stuck.
I would assume that .tfignore works the same with local and server workspaces, so:
Yes, you have to delete \FS from source control, but doing so from the Team Explorer should suffice.
Add a .tfignore in \FSs parent directory.
This will ensure that your \FS folder does not sit in source control and get copied over when you make a new branch.
This is an old post, but I'm providing an answer anyway since I stumbled upon the same issue and finally found an answer:
Someone commented that .tfignore only works with local workspaces -> this is correct
The syntax for excluding entire subfolders within your current folder (where your .tfignore file resides) can be either of those:
/subfolder
\subfolder
If you want to exclude subfolders of subfolders or files in subfolders of it can be either of those or something similar (depending on what you want to filter out):
/subfolder/subsubfolder
\subfolder\subsubfolder
/subfolder/*.txt
\subfolder*.txt
It is noteworthy that tf.exe has some strange quirks, when anything isn't right nothing in .tfignore will have effect and you will not receive any visible error message (maybe hidden somewhere in some log, not sure). At first I thought I was having some issue with line endings, because when I added a new line with a new entry then nothing got excluded, only after adding a blank line in between. Later I noticed that it seems like tf.exe is doing some kind of validation that doesn't always succeed the first time for certain syntaxes. Hard to put my finger on under what scenarios exactly that happens, but it works the second time.
I suggest anyone doing this having the text editor open and save your changes in .tfignore, then check in Team Explorer if the detected files disappear (which they should if they're ignored). When this doesn't work within 1 to 3 seconds, try just saving the .tfignore file again without changing anything, then it'll probably work. I've seen this bevahior now 100 times.
After editing and saving .tfignore file:
After a blank re-save of the file:

tfignore wildcard directory segment

Is it possible using .tfignore to add a wildcard to directories? I assumed it would have been a case of just adding an asterisk wildcard to the directory segment. For example:
\path\*\local.properties
However this does not work and I am unsure how I would achieve such behaviour without explicitly declaring every reference that I need excluding. .
Documentation
# begins a comment line
The * and ? wildcards are supported.
A filespec is recursive unless prefixed by the \ character.
! negates a filespec (files that match the pattern are not ignored)
Extract from the documentation.
The documentation should more correctly read:
The * and ? wildcards are supported in the leaf name only.
That is, you can use something like these to select multiple files or multiple subdirectories, respectively, in a common parent:
/path/to/my/file/foo*.txt
/path/to/my/directories/temp*
What may work in your case--to ignore the same file in multiple directories--is just this:
foo*.txt
That is, specify a path-less name or glob pattern to ignore matching files throughout your tree. Unfortunately you have only those two options, local or global; you cannot use a relative path like this--it will not match any files!
my/file/foo*.txt
The global option is a practical one because .tfignore only affects unversioned files. Once you add a file to source control, changes to that file will be properly recognized. Furthermore, if you need to add an instance of an ignored name to source control, you can always go into TFS source control explorer and manually add it.
It seems this is now supported
As you see I edited tfignore in the root folder of the project such that any new branch will ignore its .vs folder when being examined for source control changes
\*\.vs
Directory/folder name wildcarding works for me in VS2019 Professional. For example if I put this in .tfignore:
*uncheckedToTFS
The above will ignore any folder named ending with "uncheckedToTFS", regardless of where the folder is (it doesn't have to be top level folder, can be many levels deep).

Resources