Mercurial (hg) ignore my change on file but keep updating - maven

Is it possible that I could use mercurial (hg) to ignore the changes on my local but always get the latest one and remind me of the changes when conflicts?
e.g. I have a pom.xml file which use a less plugin, but I definitely dont want the less plugin get run every time when I change a file in the eclipse and it triggers the maven update. But I will need it when it goes to production.
So is it possible I could just ignore my changes on the pom.xml file (comment out the less plugin) but not commit it and still get the updates when some other changes on pom.xml incoming.

You can't do this with .hgignore, as that only instructs Mercurial which untracked files to ignore.
You can achieve what you want by not committing changes to pom.xml:
hg commit --exclude pom.xml
You'll need to remember to will be a manual operation every commit, or you can add something like the following to your .hgrc or Mercurial.ini:
[alias]
mycommit = commit --exclude pom.xml
hg mycommit will now always exclude pom.xml

Related

How can I add additional dependencies for my maven project without committing it to pom.xml file?

I want to add a dependency for example Spring Developer Tools. I understand that I can add it to the pom.xml file, but that'll make git show the addition as an uncommitted change. I don't want to commit this, it'll be just for my local testing.
Is there a way I can have a secondary pom.xml file for this dependency and then I can add that to .git/info/exclude so that it can be ignored?
do a new git branch and put your changes there for testing. Example
git checkout -b "feature/playground"
Modify your pom, than you can apply your changes to your testing branch.
git add -u
git commit -m "Devtools added"
if you need to go back to your unchanged branch.
git checkout master
if master is your main branch.
This is by far best solution. If you for some un clearly reasons want avoid of pushing devtools into your master branch.
But to answer you Question directly. Depend on your IDE, you can add a Dependencie without to change your pom. For that you need to download the .jar you want to add.
And than add it via UI of your IDE. Here is an example how it looks like in JetBrains IntelliJ IDEA

Spring and GitHub: hide sensitive data

I have a repository on GitHub that I would like to make public so recruiters can view it.
This repository though holds my SMTP and a MongoDB URI that shouldn't be shared with others. This information is in my application.properties file.
What's the simplest way to hide this sensitive data and also make sure no one can go look at old commits and see how it was before hiding it?
I have seen some ways on the web but they all look quite complicated...
Thank you for your experience and time
Use environment variables to hide your sensitive data. Like
spring.data.mongodb.host=${MONGO_DB_HOST}
spring.mail.host=${MAIL_HOST}
Set the values at your dev environment.
I don't have any idea about how to hide your old commits.
Make a .gitignore file at the root of your project and inside list whatever files you don't want git to have access to it when you push into GitHUb, for example:
/public/packs
/node_modules/
.pnp.js
/ (forward slash) is used for folders and
. (dot) is used for files
Here follows a picture of the location of the .gitignore file.
If the goal is just for recruitment, would it be acceptable to have a second copy for recruitment, while leaving the original copy alone?
While there's certainly more idiomatic ways of achieving this through git, a simple solution with minimal git knowledge or advanced techniques would be:
Create a new empty git project on GitHub
Clone the new project locally
Copy the (non-.git) files from the existing project into the new project (using either the console or your OS's windowed UI)
Delete or redact the offending entries from the new project
Commit the changes as a single commit
Push the new project back to GitHub
I have not used it myself, but the open source BFG Repo-Cleaner looks like it might satisfy your requirements of simplicity while retaining the activity chart for reviewers to view. This can be done on a publicly-facing copy of the repo if you wish to keep your private working copy, while still keeping the activity history viewable.
Following the tool's usage instructions, you should be able do the following (assuming you want these changes in a fresh copy of the repo):
The first step is to duplicate the repository on GitHub, following the instructions in the GitHub docs.
To do this, first create a new repository.
Next, mirror the repository, following the GitHub instructions:
Open Terminal.
Create a bare clone of the repository.
$ git clone --bare https://github.com/exampleuser/old-repository.git
Mirror-push to the new repository.
$ cd old-repository.git
$ git push --mirror https://github.com/exampleuser/new-repository.git
Remove the temporary local repository you created earlier.
$ cd ..
$ rm -rf old-repository.git
Now that you have the duplicate repository, you can run the BFG Repo-Cleaner to replace all instances of text you want hidden with ***REMOVED***.
$ java -jar bfg.jar --replace-text replacements.txt my-repo.git
The replacements.txt file would contain the SMTP, MongoDB URI, and any other text you want hidden.
mongodb://my-username:my-password#host1.example.com:27017,host2.example.com:27017/my-database
marco-f#example.com
Note that this does not update the latest commit on the master/HEAD branch, so this will need to be manually changed, and then committed. This can either achieved using a final commit using the --amend option, or by making a new commit prior to running the BFG Repo-Cleaner with the files manually changed.
$ git commit --amend
Now that the changes have been made, they can be pushed to GitHub.
$ git push

Mercurial refuses to not ignore Gradle wrapper artifacts

My .hgignore file looks like this:
syntax: glob
# mercurial files
*.orig
*.rej
# build target and dependency directories
*/target/**
*/target-eclipse/**
.gradle/**
.gradle
*.war
*/wrapper/**
!gradle/wrapper/gradle-wrapper.jar
!gradle/wrapper/gradle-wrapper.properties
*/out/**
*/build/**
# IDE files
.idea/**
.settings/**
*.iml
*.ipr
*.iws
*.classpath
*.project
# LazyBones
.lazybones/**
# DropWizard
config.yml
config.json
# JMeter Results
*/jmeter/results/*
Pay attention to my attempt to exclude gradle/wrapper/* from this ignore file:
!gradle/wrapper/gradle-wrapper.jar
!gradle/wrapper/gradle-wrapper.properties
When I run gradle wrapper on my project it generates typical Gradle wrapper files. However when I hg add I don't see those files (gradle-wrapper.jar and gradle-wrapper.properties) added to hg tracking, and when I push my project (hg push) I don't see them showing up on the remote repo.
Have I misconfigured .hgignore somehow? is hg still actually ignoring my Gradle wrapper artifacts?
For two specific files, you should just add them manually:
hg add gradle/wrapper/gradle-wrapper.jar gradle/wrapper/gradle-wrapper.properties
hg commit
This will work even if they are ignored, and changes will be picked up by subsequent commits automatically.

Jenkins- SVN poll won't work if take checkout using shell script

We have a maven project for which we have set up jenkins for build. The reporsitory has a large tools folder which i didn't want Jenkins to download.
I just want jenkins to download src folder and pom.xml file.
I added two reporsitory locations in Jenkins - only to learn that Single file checkouts are not possible
This forced me to use shell script option provided by Jenkins for checking out pom .xml . PFB the script outline.
svn checkout $pomUrl . --depth empty
svn update pom.xml
I did not find an option in my scm plugin of Jenkins to do an empty checkout
Checkout one file from Subversion
But POLL SCM of jenkins is only polling the src folder and builds are not triggered if i make some changes to pom.xml. Is there a way to ensure Polling of my pom.xml as well?
No. Jenkins will poll what it knows.
In your scenario:
Jenkins doesn't know about your pom.xml.
Jenkins doesn't work in single file checkouts anyways.
You will have to rearrange your structure, either move the tools folder outside of the main checkout (if it's so large that it's prohibitive, why do you have it in the root location?), or move the pom.xml into the src folder.
Edit:
Here is an idea. Haven't tried so don't know if that will work.
Keep your manual checkout and update of that pom like you currently do.
Setup another SVN Add module....
Enter the root location of SVN where your pom is, give it a non-conflicting folder name
Configure Repository depth for that module as Empty (if you don't see this option, you may need to upgrade your SVN plugin and/or Jenkins).
Click Advanced... section.
Configure Included Regions with the path to your src folder, and the pom only.
Something like:
/trunk/myapp/src/.*
/trunk/myapp/pom.xml

Why are these files not ignored by git?

My .gitignore file contains these lines :
xcuserdata/**/*
!xcuserdata/**/xcschemes/*
But the following file is still tracked
/MyApp/MyApp.xcodeproj/xcuserdata/colas.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
Why is it so? How can I fix that?
PS: If I had MyApp.xcodeproj/xcuserdata/colas.xcuserdatad/xcdebugger, the files are ignored. But I don't understand why it does not ignore them without this "hack".
EDIT 1
Contrary to what is said in one of the answer, the pattern
xcuserdata/**/*
!xcuserdata/**/xcschemes/*
works !!! I mean, the files under /xcschemes are tracked.
See also the post Git ignore file for Xcode projects, where I get this .gitignore file.
EDIT 2
My Git version is 1.8.3.4 (Apple Git-47).
EDIT 3
When I git check-ignore this file, here is what I get
fatal: Not a git repository (or any of the parent directories): .git
But the fact is that a parent directory is a git directory...
EDIT 4
When I git check-ignore --no-index -- this file, here is what I get
[MT] PluginLoading: Required plug-in compatibility UUID 37B30044-3B14-46BA-ABAA-F01000C27B63 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XcodeSnippetsHelper.xcplugin' not present in DVTPlugInCompatibilityUUIDs
2014-02-10 10:03:50.856 xcodebuild[1496:d07] XcodeColors: load (v10.1)
2014-02-10 10:03:50.859 xcodebuild[1496:d07] XcodeColors: pluginDidLoad:
fatal: Not a git repository (or any of the parent directories): .git
EDIT 4bis
From the root folder :
if I don't use the no-index option, there is no reply to git check-ignore.
if I use the no-index option: I get the error error: unknown option 'no-index'...
Strange ;-!
First, you can do a git check-ignore (git 1.8.3.3+) to see what rule is ignoring your file (assuming it wasn't in the index in the first place)
Second, read ".gitignore exclude folder but include specific subfolder":
It is not possible to re-include a file if a parent directory of that file is excluded. (*)
(*: unless certain conditions are met in git 2.8+, see below)
Git doesn't list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined.
So the file of xcschemes wouldn't be un-ignored anyway.
You needed to ignore parent folder per parent folder.
But a better approach is to ignores files only, and then exclude the folder:
xcuserdata/**
!xcuserdata/**/
!xcuserdata/**/xcschemes/**
Remember:
You need to exclude folders from the gitignore rules before being able to exclude files.
Note that with git 2.9.x/2.10 (mid 2016?), it might be possible to re-include a file if a parent directory of that file is excluded if there is no wildcard in the path re-included.
Nguyễn Thái Ngọc Duy (pclouds) is trying to add this feature:
commit 506d8f1 for git v2.7.0, reverted in commit 76b620d git v2.8.0-rc0
commit 5e57f9c git v2.8.0-rc0,... reverted(!) in commit 5cee3493 git 2.8.0-rc4.
However:
The directory part in the re-include rules must be literal (i.e. no wildcards)
So that wouldn't have worked here anyway.
Adding file names to .gitignore helps prevent you from adding the files unintentionally.
If you do something like git add . to add a folder full of files to the repository, the files (or filetypes) ignored in .gitignore will not be added.
They would have to be added by using the -f flag with the git add command.
It will not change anything if the files are already tracked.
You can stop tracking the files by using the answer to the question:
Remove a file from a Git repository without deleting it from the local filesystem
edit: After rereading the question a few more times, I think you may be having roughly the same issue that was addressed in this answer:
.gitignore - ignore any 'bin' directory

Resources