Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to properly register a github fork with Bower

A while back I had to use a jQuery plugin in my project. I needed some different functionality, so I rewrote the plugin and a few days back I published a fork on github. I wanted to add the package to the bower repository.

The forked repository

I added a bower.json file to the repository and registered the package with the usual "bower register" command. The problem is, when I try to install my package, bower installs the original script and not the fork.

What I already tried:

At first I thought it's because I didn't make a release, so I fixed that part. But It didn't help.

I also tried to change the version number to the version number of the original script with no luck.

So maybe the bower.json file I wrote was not well written, right? My next attempt was using Bower to make a propper bower.json file for me using "bower init". No luck.

So what could I be doing wrong?

The GitHub help page defines a fork as a method to use someone else's project as a starting point for your own idea. That was my intention since I rewrote the plugin to be oo oriented and added some functionality, but 80% of the code used is still from the original plugin and it didn't feel right to just make a new repository. Should I instead make a new repository and will registering my repo with Bower work then?

What is the usual approach if you did some medium to major changes to a repository? Do you fork it or publish a new repo? Do you still make a pull request even if the changes are bigger?

like image 511
itd Avatar asked Aug 03 '14 12:08

itd


People also ask

When should a fork be repossessed?

Most commonly, forks are used to either propose changes to someone else's project to which you do not have write access, or to use someone else's project as a starting point for your own idea. You can fork a repository to create a copy of the repository and make changes without affecting the upstream repository.

How do I fork a Git repo from the command line?

There is no git fork command. From the command line you can clone a Git repo, you can pull from a Git repo and you can fetch updates from a Git repo, but there is no git fork command if you're working with a standard Git installation.

How do I fork my own repossession?

You can fork any repo by clicking the fork button in the upper right hand corner of a repo page. Click on the Fork button to fork any repo on github.com. Source: GitHub Guides.


2 Answers

This worked for me :

  1. Fork the repository
  2. Clone on your disk
  3. Increment the version number in bower.json (ex. 2.0.1)
  4. Commit and push
  5. Create a new version tag higher than the forked repository. ex: git tag "2.0.1"
  6. Push : git push --tag
  7. bower install "https://github.com/myname/forkedrepo.git#2.0.1"
like image 137
Alain Beauvois Avatar answered Sep 30 '22 03:09

Alain Beauvois


You don't need to create a new repository. A fork will work fine.

But you can't overload on someone else's registered package name with bower. It does look like you've changed the name from onepage-scroll to onepage-scroll-extended though.

If you want to figure out what Bower knows about your package:

Do: bower info onepage-scroll-extended

{
  name: 'onepage-scroll-extended',
  homepage: 'https://github.com/itd24/onepage-scroll-extended',
  version: '1.1.1'
}

Available versions:
  - 1.1.1
  - 1.0.1

Here you can see that it does not have the full bower.json manifest information and the latest information that it has is for version 1.1.1 (not 1.1.3, your latest).

This is because you don't have a v1.1.3 tag in your repository's master branch. I can see a v1.1.1 and v1.2 tag, but no v1.1.3 tag. Create that tag and push it up to GitHub to enable you to bower install that new version.

You may also need to re-run the bower register command to tell it to pick up the latest manifest. This should be happening automatically (AFAIK). You don't include the bower register command that you ran, perhaps you used the wrong repo URL there. You should use something like:

bower register onepage-scroll-extended [email protected]:itd24/onepage-scroll-extended.git

like image 30
Splaktar Avatar answered Sep 30 '22 03:09

Splaktar