Add Husky(Git Hooks) into Azure DevOps Project - github

My repository is on AzureDevops, and I cloned it by the button: "Clone in VS Code". The repository was cloned correctly. I have the files from package.json, .gitignore, etc...
But I don't have a .git folder. And I would like to install some tool to standardize code commits. I try to install husky 7 but it doesn't find the .git folder which doesn't really exist.
Is there any way to use git hooks for the repository within Azure Devops?
Is there any other tool for standardizing commits that works in an Azure Devops repository?
When i try to install husky, i get that error: .git can't be found (see https://git.io/Jc3F9)
husky -v = ^7.0.0,
npm -v = 6.14.12

Related

Updating NuGet reference in a different repo in Azure DevOps

I have set up a multi-repo in Azure DevOps using Git. Assume I have 2 repos (Repo A and B) for simplicity.
Repo A's outcome is a common library DLL. Repo B references Repo A's generated DLL (via a NuGet package).
The CD pipeline of Repo A pushes the NuGet package (which was packed during the CI pipeline of Repo A) to my Azure Artifacts feed.
Is there a way to add a task in the CD pipeline of Repo A to automatically change the NuGet package reference (to a newer version) in the project of Repo B? This way, when Repo B gets pulled on the local repository, the reference would be updated instead of going through the NuGet Package Manager and updating manually in Visual Studio?
Update:
After applying your suggestions, everything is working perfectly except the fact that when I pull the changes of RepoB to my local repo, the new NuGet package of Repo A is not available in the packages folder [of Repo B] and I have to manually get it from the Package Manager.
Pre-Build event helps here but I want Repo B be fully up-to-date upon pulling from Azure Repos.
Below is the CD pipeline of Repo A.
Is there a way to add a task in the CD pipeline of Repo A to automatically change the NuGet package reference (to a newer version) in the project of Repo B?
There is no such out-of-the-box approach to doing this.
The simple way is:
Add a Pre-build event to the project in the Repo B with following command line:
nuget.exe update $(ProjectDir)packages.config
In case, when Repo B gets pulled on the local repository, the reference would be updated when you build the project in the repo B. But the limitation for this way is that this method will only modify our local files and will not directly modify the files in the repo. We still need to submit the changes to the repo manually.
The Complex way is:
Add a command line task in the CD pipeline of Repo A to use git command line to clone repo B:
git config --global user.email "xxx#xyz.com"
git config --global user.name "Admin"
git clone <repo> <directory>
Then add powershell or any other task to update the Reference, HintPath info in the project file and the package version in the packages.config file.
After modifying the files, add another command line task to submit the changes to the repo:
git commit -m "Update package version"
git push -u origin master
Update:
When you use git clone <repo> <directory> to clone the repo, you need to provide your certificate in your source link, usually using PAT:
The link looks like:
https://<OrganizationName>#dev.azure.com/<OrganizationName>/MyTestProject/_git/TestSample
Then we need to replace the first OrganizationName with PAT. So, it will be:
https://<PAT>#dev.azure.com/<OrganizationName>/MyTestProject/_git/TestSample
For your case, it should be:
https://<PAT>#xxxxx.Visualstudio.com/....
Then I could clone it successfully.
Hope this helps.
This can be done a bit differently than asked.
Using Project References (Newer projects):
Change your Repo B project's package reference version to get the latest using the wilcard symbol * in the Version attribute.
<PackageReference Include="MyPackageName" Version="*" />
Using packages.config
packages.config does not support the wildcard symbol and takes a few more steps.
You will need to add the following to your nuget.config file inside the <configuration> section:
<config>
<add key="dependencyversion" value="Highest" />
</config>
Be sure that the nuget.config is a part of the repo.
Then In the pipeline's Nuget restore task under the Feeds to use section select Feed in my NuGet.config and then specify the path to the repo's nuget.config.
In either case, when Repo B compiles in the pipeline it will grab the latest. When the repo is pulled down clean or for the first time it will grab the latest on the initial compile as well and on any new version that has been published.

How to clone TFS to GitHub with history using Git-TFS?

I'm trying to clone a GIT repository in TFS using git-tfs using TFS 2012
git tfs clone http://sourcecontrol.oldcompanyname.local:8080/tfs/foo $/companyname/myrepository . --b=all --resumable
Gives me:
error: the path $/companyname/myrepository you want to clone doesn't exist!
I have an empty repository called /companyname/myrepository in my github account
(the urls and names are genericized for the public post)
Git TFS is for converting TFVC repositories to local Git repositories. It has nothing to do with GitHub. Once you have a local repo, you can add a GitHub remote and push it there.
The clone URL should be the path to your TFS instance, stopping at the project collection. http://companyname.local:8080/tfs/DefaultCollection.
The next part is the path to a folder in the TFVC repository. If you have a team project named Foo and you want to clone the Main branch, you'd specify $/Foo/Main.

Import a vs 2017 solution git repo into azure devops

I am trying to use appcenter with azuredevops services.
I have created a solution "HelloWorld" on local PC in VS 2017 and added to local Git repository
I have created a project in AzureDevOps "MobileApps"
How do I import my new shiny solution in VS2017 "HelloWorld" into AzureDevOps?
Any walkthrough?
I can make it work if
I start from azuredevops and clone in visual studio.Bcse I then get a prompt in visual studio to create a new solution in the new cloned repo.
But Cannot find a way to import a repository from Visual studio into AzureDevOps.
Links that i saw but did not work .Also outdated with azuredevops.
How to Import project code from local machine to Azure Repos?
You should be following these steps to add your local git repo to Azure DevOps
Create a git repo in Azure DevOps repos
Copy the clone url from Azure DevOps and use below command to configure your local repo to use Azure DevOps repo as the remote repo. Edit command from local git repo root folder.
git remote add origin <url-from-Azure repos>
Then you should be able to push your local content to Azure repos..you can use below commands
git add .
git commit -m 'your comment'
git push -u origin master

Publish npm package project directly to github repository

Please note, i'm new to npm package manager.
I've created a simple bootstrap 4 sass+gulp starter project using npm package commands and scripts. Now i want to publish this project in a new github repository. I understand i can manually create a github repo, copy my project files and commit.
However, im curious
- to learn the better workflow / approach.
- Is there any npm tool /workflow for any github integration, for publishing?
- Is that the better approach first to create the github repository for any such project? clone then do other stuffs?
This time its only the artifacts. But, latter it might be a project with source where the project dependent artifacts will hold in npm package manager. However, i also noticed that lots of artifacts available in npm packages also has a github repo.
Git Commit
git add -A . && git commit -a -m 'gh-pages update'
Publish to Git
git push origin gh-pages --force && git checkout master
Make sure you're inside the folder of the package you need to publish onto Github for all the commands to work.
Publish to NPM
(Just in case)
Make sure you have name and package entries in your package.json file, then:
npm adduser
Verify that your user is set properly by running npm config ls finally npm publish should do the trick

I want to put a new project on Github

I have a java/GWT project in eclipse , There is a Git repo git#github.com:example/example.git
where i want to put my complete project for the first time
Please guide me how can i do this , I am new to Github
I have searched a lot ,but couldn't able to do it successfully
I do have GIT Bash and GIT GUI
Thanks
Note that instead of having a msysgit installation (git bash and git gui), you could install on Windows the new windows.guthub.com:
That will facilitate cloning that repo.
The other alternative is to declate and clone it through Egit within Git, as described in this tutorial: Using Egit with GitHub.
Note that Eclipse+Egit means you don't have to install a msysgit (it is still recommended though, to benefit from the rich CLI of git outside Eclipse).
Follow the setup and create a repo instructions on github itself.
Basically you're going to do the following:
Install git on your development pc.
git init to create a local git repository for your project.
git add your files to the local repository.
git commit changes to the local repository.
git push to the remote github server when necessary.
Search Stack Overflow - try this post for starters: Git for beginners: The definitive practical guide