Single gitbook from multiple repositories - gitbook

I want to use gibook to publish some documentation. My repo is something on the following lines
docs/
libs/
sub-module-1
sub-module-2
sub-module-1 looks a little like this
src/
docs/
install.md
blah.md
I am not sure if GitBook supports the ability to create a single gitbook where i can combine markdowns from both main repo and submodule repos.
I am also ofcourse also head scratching on how sync would work as main could be linking to a different commit hashes of submodules and not exactly clear if i were to modify sub-module-1/docs/install.md how would this get updated.
Nuclear option being , i move the docs out from submodules to the higher level main repo , but would like to keep them as close as possible. So exploring if there is a better way to organise this.

Related

Change a folder path for commit in Gitlab

Is there a way to modify folder structure (path) for pushed commits in Gitlab?
For example, my old path is homework, now I want to add a parent folder before that, i.e. superfolder/homework? Tks and welcome for any help
If you want to do so while keeping the history of homework, you need to install the Python-based tool newren/git-filter-repo.
That tool has a renaming based on paths option
In your case:
git filter-repo --path-rename homework:superfolder/homework
Note that it changes the history of the repository, which will have to be forced pushed (git push --force): not a big deal if you are the only one working on it.

ES6 imports: pick up updates to external project

We are starting a new project using angular2, typescript and gulp. For the time being our application will consist of two subprojects: a components library (which in the future might be spun off into a separate project) and the app using the component library.
The layouts of the project is going to be something along the lines:
/project_root
/component_library
/src
/library
/components
/services
... etc
/application
/src
/app_name
/components
/services
... etc
The components in application will be using components from the library (but not the other way round)
We would like to have clean (non relative) imports in the app components when importing stuff from the library (we want to avoid ugly imports of the sort '../../../component_library/src/library ...etc' plus, what's more important, we want to be able to move the library code to a separate project without the need to update imports.
There are two possible solutions I see (don't like any of them):
Add a gulp task that would watch the component library and on every change copy the file to node_modules in /project_root
Some sort of simlink? so that we can point /project_root/node_modules to /project_root/component_library/src?
I'm afraid the first solution might not work well with IDE autocomplete in the application (first gulp would need to do the compilation/copying then the IDE would need to pick up the change from node_modules - this looks like something that can be really slow)
The second solution feels hacky - it would need to be repeated by everyone who checks out the code from repo.
What would be the best solution here?
what's more important, we want to be able to move the library code to a separate project without the need to update imports.
Ship your component_library with source and add it as a node_module dependency. Then when someone pulls your code they can add a git remote to node_modules/component_library code and work on the two projects seemlessly.
This is the approach I took with ntypescript.

TFS Best way to handle branches and project references

I have the following TFS configuration
Root\
Proj1\
App1\
...
App2\
...
Proj2\
Lib1\
...
Lib2\
...
App1 and App2 both have project references to Lib1 and Lib2.
App1 does not reference App2, and Lib1 does not reference Lib2.
Now, I want to make changes to Lib1... but I want to branch it because the changes are drastic. These changes shouldn't require changes in either app1 or app2.
I created a branch Lib1Branch1 in TFS... but App1 and App2 both still reference Lib1 rather than lib1branch1... I don't want to manually re-reference the branch in each App (In actuality I have much more than just two).
When I used SVN, if I branched a project, and switched to that project, the local folders kept their original names and only the contents changed... thus building with one branch of the lib vs. building with the other only required that I switch branches and do a get-all... how do I get similar behavior using TFS?
I think you have a misunderstanding.
A Project is a self contained piece which is part of a larger thing called a solution. For example, a single class library is one project. It may reference other projects.
There are several ways to do branching. Minor branches might just require branching a particular project within the solution (such as Lib1) while major changes might require branching the entire solution.
It sounds like what you need to do is change your TFS structure slightly, then branch the entire thing. For example, the folder structure should probably be similar to the following:
Root
\1.0
\Web Apps
\App1
\App2
\Libraries
\Lib1
\Lib2
Then, when you branch, you take the entire 1.0 branch. That way all references are preserved between the two branches.

Instancing files in Perforce across multiple locations

Maybe some Perforce gurus could provide some advice.
We have a depot, with a setting.xml file in central folder:
///depot/central/config/setting.xml
and would like it to be instanced in several locations, like:
///depot/projectA/tool1/config/setting.xml
///depot/customerB/tool2/config/setting.xml
The benefit is for maintenance. the setting.xml file only has to be updated once in //depot/central, then all files in the other places get updated as well, so we don't have to get into each place, duplicate it again and again.
AlienBrain has a feature called 'shortcuts', does Perforce have something similar?
We've tried use the OS' symbolic links feature, but it didn't behave the way expected -- cloned files still need to be checked-out first, then check them in again -- this makes the cloned files own their own revisions against the original one.
It's better to just keep the original and cloned files have the same revisions. so if submitting a new revision to setting.xml(5/5)(which makes it to be setting.xml(6/6)), the cloned files as this point still remains setting.xml(5/6). Thus, people on projectA & customerB can simply sync to the latest version.
Thanks.
You can use the Perforce client spec to map files from the depot into your workspaces, which should do almost exactly what you're looking for.
For example, your client spec for tool 1 would be something like:
//depot/projectA/tool1/... //workspace_for_tool1/...
//depot/central/config/setting.xml //workspace_for_tool1/config/setting.xml
And your client spec for tool 2 would be something like:
//depot/customerB/tool2/... //workspace_for_tool2/...
//depot/central/config/setting.xml //workspace_for_tool2/config/setting.xml
The main downside of this approach is that you need to make this change in every client spec, and you need some infrastructure dedicated to propagating client specs to new workspaces.

Perforce and submodules

At work we are using Perforce and I wonder if it's possible to do submodules with it with versioning.
For example I have library A used by projects B and C.
I want to make it so that when I get revision of B I also get A in subfolder:
B
---=> A(v1)
Same goes for project C, but it would need newer version of library.
C
---=> A(v1.2)
I know this kind of thing is possible with Git, but could not find anything on it for Perforce.
Thanks,
Leonty
Perforce really handles this sort of thing with views and paths. These let you assemble the right set of files to put into a workspace (or branch or label). Since a Perforce repository can contain all of the components or modules for all your products, you just select which ones you want in a working data set. You don't need the submodule (or SVN external) concept to pull in data from another repository.
You can use template workspaces to make sure that developers get the right set of files to work on. You can be a little more rigorous and write some custom tools (possibly in the Perforce broker) to provide some structure.
The closest equivalent to using submodules is found in Perforce streams, where the paths define what goes into a stream. Stream paths are inherited by child streams. This isn't a direct equivalent though.

Resources