Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignoring files from checkin with certain pattern of change

Since having started using JetBrains Annotations, for my own benefit I've decorated all methods with [CanBeNull] or [NotNull]

For example, the following line:

public AccountController(IAccountService accountService)

Would be changed to:

    public AccountController([CanBeNull] IAccountService accountService)

Another example would be:

public Account CreateAccountEntity(Account accountEnttity)

would be changed to:

    [CanBeNull]
    public Account CreateAccountEntity([NotNull] Account accountEnttity)

How can I bypass pending changes for annotations, specifically "[CanBeNull]", and have TFS completely ignore this change?

like image 326
Alex Gordon Avatar asked Jan 17 '17 01:01

Alex Gordon


3 Answers

You cannot make TFS "ignore" the change. That is the purpose of TFS - to track all changes.

The way I interpret your question, you are wanting to avoid the noise of potentially many small but innocuous checkins due to your annotations. If this is correct then there is a way to use TFS that will minimize the noise:

  • create a branch from where you are currently working (let's call it "BranchA"), then make all the annotation changes in that new branch ("BranchB"), checking them in regularly
  • if this is going to take some time (days, weeks) to complete then ensure you do regular merges from BranchA to BranchB
  • when you think you've finished do a final merge from BranchA to BranchB. If you've pulled across any new methods then ensure you annotate them. Repeat this step if you made changes.
  • merge all changes from BranchB back to BranchA. This will have the effect of aggregating all your smaller changes into a single large checkin/changeset in BranchA. Provided you have been doing regular merges from BranchA to BranchB this should be problem free even if considerable time has passed since you started the decoration work.
like image 78
slugster Avatar answered Oct 08 '22 22:10

slugster


In short, you shouldn't, the closest feature is the tfignore, but this will ignore all file.

On the other hand, if you really want this, you could create a tool using the TFS API, and you would have to run this before check-ins and it would verify all the pending files in your solution and looking for this small changes and excluding the files, but this could cause the problem that at some point you may make a change to an excluded file and it won't get checked in and cause problems. You would need to add extra code to verify what files should be included from the excluded list.

External tool used inside VS Here you can see how to add tools to the Tools menu and send arguments to it.

TFS API Example This example shows how to use the TFS API. There is a 'workspace.AddIgnoreFileExclusion()', but I don't have TFS here, so I'll verify how to ignore the files later.

Now in my experience, the only reason I wouldn't want to check in those changes would be to avoid conflicts with the team. If I see a lot of value in some practice like using the annotations, I would talk with the team to get them to buy in into the idea of using annotations, that way everyone would be using it and soon every file will have the annotations and there won't be any conflicts.

like image 20
AL - Divine Avatar answered Oct 09 '22 00:10

AL - Divine


You can't selectively ignore changes within files, in TFVC or in any other SCM I've ever encountered.

like image 34
Daniel Mann Avatar answered Oct 09 '22 00:10

Daniel Mann