$$f(x) = \begin{cases} x-1, \quad& -\pi < x <0 \\ x+1, & 0 \leq x \leq \pi \end{cases}$$
This is odd so we expand with an odd series
$$b_n = \frac{2}{\pi} \int_{0}^{\pi} (x+1) \sin(nx) \,\mathrm{d}x.$$
Question: Isn't $L = \pi$ so where does the $2$ come from? Also how do I know whether to use $x+1$ or $x-1$?
If your function $f$ is odd, then the formula is $$b_n = \frac{\color{blue}{2}}{L}\int_0^L f(x)\sin\left(\frac{n\pi x}{L}\right)\, dx,$$ so this is why there is $2$.
The reason this formula has a $2$ is that the integrand is even when $f$ is odd, so the usual formula $b_n = \frac{1}{L}\int_{-L}^L f(x)\sin\left(\frac{n\pi x}{L}\right)\, dx$ gives us the above one. (Remember that $\int_{-a}^a g(x)\, dx = 2\int_0^a g(x)\, dx $ if the integrand is even.)
In this formula, you are integrating on the interval $[0,L]$, so you use the formula for $f(x)$ that is valid on $[0,L]$. In your case (with $L=\pi$), this means you use $f(x)=x+1$ for the integral.